-
-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: experiment taskfile envs take precedence over os envs
- Loading branch information
Showing
5 changed files
with
101 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
--- | ||
draft: false # Hide in production | ||
slug: '/experiments/env-precedence' | ||
--- | ||
|
||
# Env Precedence (#1038) | ||
|
||
:::caution | ||
|
||
All experimental features are subject to breaking changes and/or removal _at any | ||
time_. We strongly recommend that you do not use these features in a production | ||
environment. They are intended for testing and feedback only. | ||
|
||
::: | ||
|
||
:::warning | ||
|
||
This experiment breaks the following functionality: | ||
|
||
- environment variable will take precedence over OS environment variables | ||
|
||
::: | ||
|
||
:::info | ||
|
||
To enable this experiment, set the environment variable: `TASK_X_ENV_PRECEDENCE=1`. | ||
Check out [our guide to enabling experiments ][enabling-experiments] for more | ||
information. | ||
|
||
::: | ||
|
||
Before this experiment, the OS variable took precedence over the task environment variable. This experiment changes the precedence to make the task environment variable take precedence over the OS variable. | ||
|
||
Consider the following example: | ||
|
||
```yml | ||
version: '3' | ||
|
||
tasks: | ||
default: | ||
env: | ||
KEY: 'other' | ||
cmds: | ||
- echo "$KEY" | ||
``` | ||
Running `KEY=some task` before this experiment, the output would be `some`, but after this experiment, the output would be `other`. | ||
|
||
If you still want to get the OS variable, you can use the template function env like follow : `{{env.OS_VAR}}`. | ||
|
||
```yml | ||
version: '3' | ||
tasks: | ||
default: | ||
env: | ||
KEY: 'other' | ||
cmds: | ||
- echo "$KEY" | ||
- echo {{env "KEY"}} | ||
``` | ||
Running `KEY=some task`, the output would be `other` and `some`. | ||
|
||
{/* prettier-ignore-start */} | ||
[enabling-experiments]: ./experiments.mdx#enabling-experiments | ||
{/* prettier-ignore-end */} |