Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc/ci/jobs
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-05-14 18:10:35 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-14 18:10:35 +0300
commit7172fb10313a9a7790f8e033b347e77df4987154 (patch)
treefe1fda5411240ba303bdd1032d12a94ccd58c27c /doc/ci/jobs
parent793d974d7c4bd8c9cbd437a9e35087092f4e8bea (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/ci/jobs')
-rw-r--r--doc/ci/jobs/job_control.md44
1 files changed, 43 insertions, 1 deletions
diff --git a/doc/ci/jobs/job_control.md b/doc/ci/jobs/job_control.md
index 14555a05672..6e9197c223b 100644
--- a/doc/ci/jobs/job_control.md
+++ b/doc/ci/jobs/job_control.md
@@ -63,7 +63,7 @@ except `main` and branches that start with `release/`.
### `only: variables` / `except: variables` examples
-You can use `except:variables` to exclude jobs based on a commit message:
+You can use [`except:variables`](../yaml/README.md#onlyvariables--exceptvariables) to exclude jobs based on a commit message:
```yaml
end-to-end:
@@ -223,6 +223,48 @@ test:
- "README.md"
```
+## Use predefined CI/CD variables to run jobs only in specific pipeline types
+
+You can use [predefined CI/CD variables](../variables/predefined_variables.md) to choose
+which pipeline types jobs run in, with:
+
+- [`rules`](../yaml/README.md#rules)
+- [`only:variables`](../yaml/README.md#onlyvariables--exceptvariables)
+- [`except:variables`](../yaml/README.md#onlyvariables--exceptvariables)
+
+The following table lists some of the variables that you can use, and the pipeline
+types the variables can control for:
+
+- Branch pipelines that run for Git `push` events to a branch, like new commits or tags.
+- Tag pipelines that run only when a new Git tag is pushed to a branch.
+- [Merge request pipelines](../merge_request_pipelines/index.md) that run for changes
+ to a merge request, like new commits or selecting the **Run pipeline** button
+ in a merge request's pipelines tab.
+- [Scheduled pipelines](../pipelines/schedules.md).
+
+| Variables | Branch | Tag | Merge request | Scheduled |
+|--------------------------------------------|--------|-----|---------------|-----------|
+| `CI_COMMIT_BRANCH` | Yes | | | Yes |
+| `CI_COMMIT_TAG` | | Yes | | Yes, if the scheduled pipeline is configured to run on a tag. |
+| `CI_PIPELINE_SOURCE = push` | Yes | Yes | | |
+| `CI_PIPELINE_SOURCE = scheduled` | | | | Yes |
+| `CI_PIPELINE_SOURCE = merge_request_event` | | | Yes | |
+| `CI_MERGE_REQUEST_IID` | | | Yes | |
+
+For example, to configure a job to run for merge request pipelines and scheduled pipelines,
+but not branch or tag pipelines:
+
+```yaml
+job1:
+ script:
+ - echo
+ rules:
+ - if: $CI_PIPELINE_SOURCE == "merge_request_event"
+ - if: $CI_PIPELINE_SOURCE == "scheduled"
+ - if: $CI_PIPELINE_SOURCE == "push"
+ when: never
+```
+
## Regular expressions
The `@` symbol denotes the beginning of a ref's repository path.