GitLabCI:Rules
if Examples
Other commonly used variables for if clauses:
-
if: $CI_COMMIT_TAG
- If changes are pushed for a tag.
-
if: $CI_COMMIT_BRANCH
- If changes are pushed to any branch.
-
if: $CI_COMMIT_BRANCH == "main"
- If changes are pushed to main.
-
if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- If changes are pushed to the default branch. Use when you want to have the same configuration in multiple projects with different default branches.
-
if: $CI_COMMIT_BRANCH =~ /regex-expression/
- If the commit branch matches a regular expression.
-
if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && $CI_COMMIT_TITLE =~ /Merge branch.*/
- If the commit branch is the default branch and the commit message title matches a regular expression. For example, the default commit message for a merge commit starts with Merge branch.
-
if: $CUSTOM_VARIABLE !~ /regex-expression/
- If the custom variable CUSTOM_VARIABLE does not match a regular expression.
-
if: $CUSTOM_VARIABLE == "value1"
- If the custom variable CUSTOM_VARIABLE is exactly value1
-
if: ($CI_COMMIT_BRANCH == "release" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH) && $ANOTHER_VARIABLE
- OR, AND condition