Skip to content

Exchange values between task and deps using dotenv files.#2711

Open
trulede wants to merge 1 commit intogo-task:mainfrom
trulede:PR/exchange-vars-with-dotenv-files
Open

Exchange values between task and deps using dotenv files.#2711
trulede wants to merge 1 commit intogo-task:mainfrom
trulede:PR/exchange-vars-with-dotenv-files

Conversation

@trulede
Copy link
Contributor

@trulede trulede commented Mar 1, 2026

This PR allows the exchange of variables between tasks, and depend tasks, using the dotenv mechanism.

If a task has deps and dotenv then the dotenv files are reloaded which makes them available in the environment of subsequent task commands.

Using this method the task does not need to be recompiled, which avoids complexities which might occur if templated variables in a task would change.

Fixes #1381 (and many others)
Fixes #1575
Fixes #2385
Fixes #1449

Alternative to #1746 (improves upon)
Related to #1627 (alternative to)

In general, works as you might expect:

version: '3'
tasks:
  gen:
    cmds:
      - echo "BAR=bar" > .genenv  
  default:
    dotenv:
      - .genenv
    deps:
      - gen
    cmds:
      - echo "BAR=$BAR"

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

Labels

None yet

Projects

None yet

1 participant