Conditional Execution & Triggers
|
Run job only for specified refs (branches, tags).
|
|
Run job for all refs except specified ones.
|
|
job_name:
stage: ...
script: ...
only:
- main
- tags
|
More flexible conditional execution based on various conditions.
|
job_name:
stage: ...
script: ...
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: always
- when: never
|
if - Specifies the condition.
when - Specifies when to run the job (always , on_success , on_failure , manual , delayed , never ).
|
Trigger pipelines from other pipelines or external sources.
|
trigger_job:
stage: deploy
trigger:
project: group/project
branch: main
|
Use trigger: to specify the project and branch to trigger.
|