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
#...
Depend 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
Why dependencies
and needs
?
dependencies
Has been around longer
Only intended for artifacts
needs
Handles job execution order
Can be used for artifacts
See chapter Job dependencies
needs
If you have one stage with two jobs where one depends on the other using needs
, artifacts are passed correctly between them.
This is important to note because without needs
jobs in the same stage to not receive artifacts from each other.