Rules define whether to execute a job
Pipeline requires one successful rule for the job to be added
job_name:
rules:
- if: $VAR == "value"
- if: $VAR2 = "value2"
# ...
Conditions are also used in workflow rules
Official documentation of job control
Formerly only
/except
but “not actively developed”
Run the deploy
job only for the main
branch
public
in repositorypublic/
to new folder public
.gitlab-ci.yml
Disable execution for some trigger types
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'push'
- if: $CI_PIPELINE_SOURCE == 'web'
- if: $CI_PIPELINE_SOURCE == 'schedule'
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == 'pipeline'
- if: $CI_PIPELINE_SOURCE == 'api'
when: never
- if: $CI_PIPELINE_SOURCE == 'trigger'
when: never