In GitLab, CI/CD rules are the key to managing the flow of jobs in a pipeline. One of the powerful features of GitLab CI/CD is the ability to control when a CI/CD job runs, which can depend on the context, the changes made,
workflow rules
, values of CI/CD variables, or custom conditions. In addition to using
rules
, you can control the flow of CI/CD pipelines using the following keywords:
needs
: Establishes relationships between jobs and is commonly used in DAG pipelines
only
: Defines when a job should run
except
: Defines when a job should not run
workflow
: Controls when pipelines are created
Note:
only
and
except
should not be used with
rules
because this can lead to unexpected behavior. You will learn more about effectively using
rules
in the subsequent sections.