Transfer files between jobs using artifacts
All jobs in subsequent stages will receive the artifacts (by default)
Name artifacts
Include and exclude paths
When to create artifacts (jobs success, failure, always)
Expire artifacts
Add untracked files
Circular dependencies are detected
Test binary in a new job and stage
hello
binarytest
test
See new .gitlab-ci.yml
:
git checkout origin/160_gitlab_ci/060_artifact -- '*'
Jobs can restrict which job artifacts to receive
job_name:
dependencies:
- other_job
#...
Empty list disables receiving artifacts:
job_name:
dependencies: []
#...
needs
1/needs
can start jobs from the next stage early…
job1:
stage: stage1
#...
job2:
stage: stage2
needs: job1
#...
…or delay them in the same stage
job1:
stage: test
#...
job2:
stage: test
needs: job1
#...
needs
2/2Depend on a job but do not consume artifacts :
job_name:
#...
job_name2:
needs:
job: job_name
artifacts: false
Consume artifacts from parent (upstream) pipeline :
job_name:
script: cat artifact.txt
needs:
- pipeline: $PARENT_PIPELINE_ID
job: create-artifact
Passing variables between jobs is possible (since GitLab 12.9)
One job defined a dotenv
artifact :
job_name:
script: echo "FOO=bar" >build.env
artifacts:
reports:
dotenv: build.env
Job in later stages automatically consume them:
job_name2:
script: echo "${FOO}"
dependencies
as well as needs
limit from which jobs they are consumed