use all rules keywords, like if, changes, and exists, in the same
rule. The rule evaluates to true only when all included keywords evaluate to true.
use parentheses with && and || to build more complicated variable expressions.
Use workflow to specify which types of pipelines
can run.
every push to an open merge request’s source branch
causes duplicated pipelines.
avoid duplicate pipelines by changing the job rules to avoid either push (branch)
pipelines or merge request pipelines.
do not mix only/except jobs with rules jobs in the same pipeline.
For behavior similar to the only/except keywords, you can
check the value of the $CI_PIPELINE_SOURCE variable
commonly used variables for if clauses
rules:changes expressions to determine when
to add jobs to a pipeline
Use !reference tags to reuse rules in different
jobs.
Use except to define when a job does not run.
only or except used without refs is the same as
only:refs / except/refs
If you change multiple files, but only one file ends in .md,
the build job is still skipped.
If you use multiple keywords with only or except, the keywords are evaluated
as a single conjoined expression.
only includes the job if all of the keys have at least one condition that matches.
except excludes the job if any of the keys have at least one condition that matches.
With only, individual keys are logically joined by an AND
With except, individual keys are logically joined by an OR
To specify a job as manual, add when: manual to the job
in the .gitlab-ci.yml file.
Use protected environments
to define a list of users authorized to run a manual job.
Use when: delayed to execute scripts after a waiting period, or if you want to avoid
jobs immediately entering the pending state.
To split a large job into multiple smaller jobs that run in parallel, use the
parallel keyword
run a trigger job multiple times in parallel in a single pipeline,
but with different variable values for each instance of the job.
The @ symbol denotes the beginning of a ref’s repository path.
To match a ref name that contains the @ character in a regular expression,
you must use the hex character code match \x40.
Compare a variable to a string
Check if a variable is undefined
Check if a variable is empty
Check if a variable exists
Check if a variable is empty
Matches are found when using =~.
Matches are not found when using !~.
Join variable expressions together with && or ||
When you use specific docker image, make sure you have the Dependency Proxy enabled so the image doesn’t have to be downloaded again for every job.
stages are used to group items that can run at the same time.
Instead of waiting for all jobs to finish, you can mark jobs as interruptible which signals a job to cancel when a new pipeline starts for the same branch