Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a5797676
Commit
a5797676
authored
Nov 06, 2020
by
Marcel Amirault
Committed by
Suzanne Selhorn
Nov 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up workflow: rules docs
parent
67978578
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
23 deletions
+27
-23
doc/ci/yaml/README.md
doc/ci/yaml/README.md
+27
-23
No files found.
doc/ci/yaml/README.md
View file @
a5797676
...
@@ -234,23 +234,23 @@ There are also two edge cases worth mentioning:
...
@@ -234,23 +234,23 @@ There are also two edge cases worth mentioning:
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/29654) in GitLab 12.5
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/29654) in GitLab 12.5
The top-level
`workflow:`
key applies to the entirety of a pipeline, and
The top-level
`workflow:`
keyword determines whether or not a pipeline is created.
determines whether or not a pipeline is created. It accepts a single
It accepts a single
`rules:`
keyword that is similar to
[
`rules:` defined within jobs
](
#rules
)
.
`rules:`
key that operates similarly to
[
`rules:` defined within jobs
](
#rules
)
,
Use it to define what can trigger a new pipeline.
enabling dynamic configuration of the pipeline.
If you are new to GitLab CI/CD and
`workflow: rules`
, you may find the
[
`workflow:rules` templates
](
#workflowrules-templates
)
useful.
You can use the
[
`workflow:rules` templates
](
#workflowrules-templates
)
to import
a preconfigured
`workflow: rules`
entry.
To define your own
`workflow: rules`
, the available configuration options are
:
`workflow: rules`
accepts these keywords
:
-
[
`if`
](
#rulesif
)
: Define a rule.
-
[
`if`
](
#rulesif
)
: Check this rule to determine when to run a pipeline.
-
[
`when`
](
#when
)
: May be set to
`always`
or
`never`
only. If not provided, the default value is
`always`
.
-
[
`when`
](
#when
)
: Specify what to do when the
`if`
rule evaluates to true.
-
To run a pipeline, set to
`always`
.
-
To prevent pipelines from running, set to
`never`
.
If a pipeline attempts to run but matches no rule, it's dropped and doesn'
t run.
When no rules evaluate to true, the pipeline does no
t run.
Use the example rules below exactly as written to allow pipelines that match the rule
Some example
`if`
clauses for
`workflow: rules`
:
to run. Add
`when: never`
to prevent pipelines that match the rule from running. See
the
[
common `if` clauses for `rules`
](
#common-if-clauses-for-rules
)
for more examples.
| Example rules | Details |
| Example rules | Details |
|------------------------------------------------------|-----------------------------------------------------------|
|------------------------------------------------------|-----------------------------------------------------------|
...
@@ -259,9 +259,12 @@ the [common `if` clauses for `rules`](#common-if-clauses-for-rules) for more exa
...
@@ -259,9 +259,12 @@ the [common `if` clauses for `rules`](#common-if-clauses-for-rules) for more exa
|
`if: $CI_COMMIT_TAG`
| Control when tag pipelines run. |
|
`if: $CI_COMMIT_TAG`
| Control when tag pipelines run. |
|
`if: $CI_COMMIT_BRANCH`
| Control when branch pipelines run. |
|
`if: $CI_COMMIT_BRANCH`
| Control when branch pipelines run. |
See the
[
common `if` clauses for `rules`
](
#common-if-clauses-for-rules
)
for more examples.
For example, in the following configuration, pipelines run for all
`push`
events (changes to
For example, in the following configuration, pipelines run for all
`push`
events (changes to
branches and new tags). Only push events with
`-wip`
in the commit message are excluded. Scheduled
branches and new tags). Pipelines for push events with
`-wip`
in the commit message
pipelines and merge request pipelines don't run, as there's no rule allowing them.
don't run, because they are set to
`when: never`
. Pipelines for schedules or merge requests
don't run either, because no rules evaluate to true for them:
```
yaml
```
yaml
workflow
:
workflow
:
...
@@ -271,11 +274,11 @@ workflow:
...
@@ -271,11 +274,11 @@ workflow:
-
if
:
'
$CI_PIPELINE_SOURCE
==
"push"'
-
if
:
'
$CI_PIPELINE_SOURCE
==
"push"'
```
```
This example has strict rules, and
no other pipelines can run
.
This example has strict rules, and
pipelines do
**not**
run in any other case
.
Alternatively,
you can have loose rules by using only
`when: never`
rules, followed
Alternatively,
all of the rules can be
`when: never`
, with a final
by a final
`when: always`
rule. This allows all types of pipelines, except for any
`when: always`
rule. Pipelines that match the
`when: never`
rules do not run.
that match the
`when: never`
rules
:
All other pipeline types run
:
```
yaml
```
yaml
workflow
:
workflow
:
...
@@ -287,12 +290,13 @@ workflow:
...
@@ -287,12 +290,13 @@ workflow:
-
when
:
always
-
when
:
always
```
```
This example never allows pipelines for schedules or
`push`
(branches and tags) pipelines,
This example prevents pipelines for schedules or
`push`
(branches and tags) pipelines.
but does allow pipelines in
**all**
other cases,
*including*
merge request pipelines.
The final
`when: always`
rule lets all other pipeline types run,
**including**
merge
request pipelines.
Be careful not to
use a configuration that might run
Be careful not to
have rules that match both branch pipelines
merge request pipelines and branch pipelines at the same time. As with
`rules`
defined in jobs,
and merge request pipelines. Similar to
`rules`
defined in jobs, this can cause
it can cause
[
duplicate pipelines
](
#prevent-duplicate-pipelines
)
.
[
duplicate pipelines
](
#prevent-duplicate-pipelines
)
.
#### `workflow:rules` templates
#### `workflow:rules` templates
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment