Skip to content

add environment variable-based configuration #1066

Description

@droopy4096

When using task in larger setups it would be more convenient to pass some of the configuration options via the environment variable so as not to update every line containing task invocation to add or remove options. Consider scenario of having several scripts with contents like:

#!/bin/sh

task target1
#....

task target2

to make them run in dry mode one has to alter all the shell scripts to include --dry option. However with environment variable configuration one can simply:

export TASK_DRY=yes

and run scripts with all task invocations picking up desired option automatically.

Of course --dry is only a sample, control of concurrency between workstation and CI node would be another good example. As well as increasing verbosity while debugging etc.

Activity

  1. jwater7 commented on Apr 22, 2024

    @jwater7
    Contributor

    I love this, exactly what I was looking for (specify the taskfile/entrypoint via an env var) - how do we get this in main so we can start using it?

  2. droopy4096 commented on Apr 24, 2024

    @droopy4096
    Author

    someone will have to review and approve #1067

  3. added
    area: uiChanges related to the UI of Task.
    and removed
    state: needs triageWaiting to be triaged by a maintainer.
    on Dec 6, 2025
  4. added theissue type on Dec 6, 2025
  5. vmaerten commented on Dec 14, 2025

    @vmaerten
    Member

    Hello!
    We’ve already added several configuration options to .taskrc, and we don’t plan to support additional ones via environment variables.
    If something is missing from .taskrc, feel free to open an issue or submit a PR.

  6. trulede commented on Dec 14, 2025

    @trulede
    Contributor

    For a lot of use cases, especially automation/CI, the preference is to use environment variables over configuration files. For these use cases, configuration files can be quite unpractical. More often than not, if a configuration file is used, that is only as a basis for operation - it is expected to use the environment to further refine that operation.

    If you take a look at git-sync, there is a good example of how to do this. Nearly every CLI option is mirrored by a environment variable:
    https://github.com/kubernetes/git-sync?tab=readme-ov-file#manual

    Now, to work around these kinds of issues it not difficult, but the question remains, why can't Task be so easy to operate?

  7. vmaerten commented on Dec 14, 2025

    @vmaerten
    Member

    I understand!
    @pd93 / @andreynering should we revisit and add env variables for each CLI / taskrc option ?

  8. jwater7 commented on Dec 14, 2025

    @jwater7
    Contributor

    For me, the most important piece of this to get is an environment variable that defines the location of the task file. If you need to change the task file that task is reading dynamically from the environment, there is currently no way of doing it.

    For example, if there is a shared build setup:

    .build-base:
      script:
        - … bunch of stuff
        - task build
    
    build-ci:
      expands: .build-base
      env:
        TASK_TASKFILE: ~/conf-ci/Taskfile.yml
    
    build-bvt:
      expands: .build-base
      env:
        TASK_TASKFILE: /opt/Taskfile.dist.yml
    
  9. andreynering commented on Dec 15, 2025

    @andreynering
    Member

    should we revisit and add env variables for each CLI / taskrc option ?

    I'm fine with adding them 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: uiChanges related to the UI of Task.

    Fields

    No fields configured for feature.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      ⌂ 换网址