needs creates dependencies between jobs in a pipeline so that jobs run as soon as their dependencies are met, regardless of the pipeline's stagesstages configuration.
artifacts is used to specify which files to saveartifacts: when :
on_success : upload artifacts when the job succeeds (default)on_failure : upload artifacts when the job failsalways : always upload artifacts, whatever the job succeeds / fails (except if it times out)dependencies and needsjob:
artifacts:
paths: relative to the project directory: $CI_PROJECT_DIR
- binaries/
- .config
this creates an artifact with .config and all the files in binaries
whenhas been somewhat misleading to me, since
type, which is one of (i.e. the corresponding job runs...) :
on_success / on_failure of previous jobsalways / nevermanually (as a manual job)when: on_successmyJob: stage: when: keyword
typeBUT has some differences :
myJob: rules: - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH if this condition is true, add job to the pipeline - if: $CI_COMMIT_REF_NAME =~ /feature/ if this other condition is true, add job to the pipeline... when: delayed ... and make it a delayed job - when: manual unconditionally make this a manual job script: - echo
rules:changes specifies that a job will only be added to a pipeline when specific files (specified as subkeys) are changedrules:changes:paths is a synonymous of rules:changes (unclear why it exists, then. Possibly a legacy 🤷♀️)changes: pathSpecOR within files listed by pathSpecchanges evaluates to true for any change in the repositoryrules: conditionsstatement is true, add the job to the pipelinestatement is true but it's combined with when: never : do not add the job to the pipelinestatement is false, check the next rules item (if any)pathSpec exists, add the job to the pipelineadding a job to a pipeline/
NOT adding a job to a pipeline/
running a job: