Driving Job Execution, Timing, and Dependencies with Conditions and Rules
57%
Customizing DAG Pipelines with Conditional Dependencies
This section explains how rules can be combined with needs to dynamically shape the DAG, so a job can depend on different upstream jobs depending on the branch context.
Example:
You want to run a job differently based on the branch name and have it depend on different jobs accordingly:
production-build:
stage: build
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script: echo "Production branch, executing full build..."
build-on-other-branches:
stage: build
rules:
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
script: echo "Non production branch, executing faster build..."
my-job:
stageCloud Native CI/CD with GitLab
From Commit to Production ReadyEnroll now to unlock all content and receive all future updates for free.
