You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/variables/index.md
+7-4Lines changed: 7 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -272,12 +272,15 @@ The environment handed to `/bin/sh` is built up in layers, each one overriding t
272
272
1. **`BaseEnv`** — the OS environment plus global `dotenv:` files
273
273
2. **Inherited parent env** — only on sub-task calls (`cmds: - task: X`); deps don't inherit
274
274
3. **Task `dotenv:`** — never overrides `BaseEnv` (i.e. global dotenv and OS env always win)
275
-
4. **Task `vars:`** — promoted into env so commands can read them with `$NAME`
276
-
5. **Task `env:`** — with cross-references resolved (see [Cross-References Between Env Entries](#cross-references-between-env-entries))
277
-
6. **Task `secrets:`** — **highest precedence**; declaring a secret overrides any same-named placeholder in `env:`
275
+
4. **Task `env:`** — with cross-references resolved (see [Cross-References Between Env Entries](#cross-references-between-env-entries))
276
+
5. **Task `secrets:`** — **highest precedence**; declaring a secret overrides any same-named placeholder in `env:`
277
+
278
+
Note that task `vars:` are **not** part of this list: vars and env are separate
279
+
namespaces. A `vars:` entry is available to `{{ "{{" }}.VAR}}` templating but is
280
+
never exported to the shell, so `$NAME` in a command only sees the layers above.
278
281
279
282
A few non-obvious consequences:
280
283
281
284
- A task `dotenv:` that names a key already set in the global dotenv (or in the user's shell) is silently ignored — see [Dotenv › Resolution Rules](../dotenv/#resolution-rules).
282
-
- Sub-tasks called from `cmds:` see the parent's resolved env (vars + dotenv + `env:` block). Same task name called from two parents with different env runs twice, because gogo bypasses task-level memoization when extra context is in play. See [Parent-to-child Env Propagation](#parent-to-child-env-propagation).
285
+
- Sub-tasks called from `cmds:` see the parent's resolved env (dotenv + `env:` block — not `vars:`). Same task name called from two parents with different env runs twice, because gogo bypasses task-level memoization when extra context is in play. See [Parent-to-child Env Propagation](#parent-to-child-env-propagation).
283
286
- A task that declares both `env: { OPENAI_API_KEY: dummy }` and `secrets: [OPENAI_API_KEY]` gets the secret value at run time. Use this pattern to keep a clear placeholder for local dev while still resolving the real value in CI.
0 commit comments