only : changes : - Dockerfile - service-one/**/* Variables in rules:changesĭocker build service one : script : docker build -t my-service-one-image:$CI_COMMIT_REF_SLUG. if: $CUSTOM_VARIABLE = "value1": If the custom variable CUSTOM_VARIABLE isĮxactly value1.if: $CUSTOM_VARIABLE !~ /regex-expression/: If the custom variable CUSTOM_VARIABLE does not match a regular expression.If the commit branch is the default branch and the commit message title matches a regular expression.įor example, the default commit message for a merge commit starts with Merge branch. if: $CI_COMMIT_BRANCH = $CI_DEFAULT_BRANCH & $CI_COMMIT_TITLE =~ /Merge branch.*/:.if: $CI_COMMIT_BRANCH =~ /regex-expression/: If the commit branch matches a regular expression.Projects with different default branches. Use when you want to have the same configuration in multiple if: $CI_COMMIT_BRANCH = $CI_DEFAULT_BRANCH: If changes are pushed to the defaultīranch.if: $CI_COMMIT_BRANCH = "main": If changes are pushed to main.if: $CI_COMMIT_BRANCH: If changes are pushed to any branch.if: $CI_COMMIT_TAG: If changes are pushed for a tag.Other commonly used variables for if clauses: Job : script : echo "Hello, Rules!" rules : - if : $CI_PIPELINE_SOURCE = "merge_request_event" - if : $CI_PIPELINE_SOURCE = "schedule" Pipelines (to branches or tags), with when: on_success (default). The following example runs the job as a manual job in scheduled pipelines or in push webide For pipelines created by using the WebIDE. web For pipelines created by using Run pipeline button in the GitLab UI, from the project’s Build > Pipelines section. trigger For pipelines created by using a trigger token. push For pipelines triggered by a git push event, including for branches and tags. pipeline For multi-project pipelines created by using the API with CI_JOB_TOKEN, or the trigger keyword. Use this pipeline source in the child pipeline configuration so that it can be triggered by the parent pipeline. parent_pipeline For pipelines triggered by a parent/child pipeline with rules. Required to enable merge request pipelines, merged results pipelines, and merge trains. merge_request_event For pipelines created when a merge request is created or updated. See Pipelines for external pull requests. external_pull_request_event When an external pull request on GitHub is created or updated. external When you use CI services other than GitLab. chat For pipelines created by using a GitLab ChatOps command. Common if clauses for rulesįor behavior similar to the only/ except keywords, you canĬheck the value of the $CI_PIPELINE_SOURCE variable: Value Description api For pipelines triggered by the pipelines API. To except: merge_requests, so job-with-no-rules Oneīranch pipeline runs a single job ( job-with-no-rules), and one merge request pipeline Job-with-no-rules : script : echo "This job runs in branch pipelines." job-with-rules : script : echo "This job runs in merge request pipelines." rules : - if : $CI_PIPELINE_SOURCE = "merge_request_event"įor every change pushed to the branch, duplicate pipelines run. Use needs to configure a job to run as soon as theĮarlier jobs it depends on finish running. To configure a job to be included or excluded from certain pipelines, use rules. You can configure jobs to run depending onįactors like the status of variables, or the pipeline type. When a new pipeline starts, GitLab checks the pipeline configuration to determine
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |