|
Note
|
|
Tasks can propagate dotenv-format values or experimental environment values to downstream tasks in a pipeline. Although file is a defined artifact type, file artifacts are not currently processed and do not propagate to downstream tasks.
Artifacts are useful inside pipelines. Use depends_on to ensure that the producing task completes before a consumer runs. Outputs are available across contexts.
The following example uses the default context to create a dotenv artifact and then consumes it from a container context. Task-level after commands run after artifact capture in the task’s configured context; they are distinct from context cleanup hooks.
summary: true
debug: true
output: prefixed
contexts:
newdocker:ctx:
container:
name: alpine:latest
envfile:
exclude:
# These are excluded by default.
- PATH
- HOME
- TMPDIR
pipelines:
tester:
- task: task:one
- task: task:two
depends_on:
- task:one
tasks:
task:one:
env:
ORIGINAL_VAR: foo123
command:
- echo "task one ORIGINAL_VAR => ${ORIGINAL_VAR} should be foo123"
- echo ORIGINAL_VAR=foo333 > .artifact.env
after:
# Runs after artifact capture in the task's configured context.
- echo ORIGINAL_VAR=shouldNOTBEUSED > .artifact.env
artifacts:
name: test_env_from_task_one
path: .artifact.env
type: dotenv
task:two:
command:
- echo "task:two ORIGINAL_VAR => ${ORIGINAL_VAR} should be foo333"
context: newdocker:ctxWhen a command assigns or exports a Bash-style variable and its artifact capture type is env, downstream pipeline tasks can consume that variable.
Prefix exported values with EIRCTL_TASK_OUTPUT_:
tasks:
run:container:nouveau:
context: nouveau:container
command: |
echo EIRCTL_TASK_OUTPUT_FOO=$FOO
env:
FOO: bar
artifacts:
type: env
consume:out:
command: |
echo $FOO
pipelines:
set-out:
- task: run:container:nouveau
- task: consume:out
depends_on: run:container:nouveau|
Note
|
The variable must be set directly in the task command, not in a script invoked by that command. |