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
d6b63b7b
Commit
d6b63b7b
authored
Aug 24, 2021
by
Matija Čupić
Committed by
Suzanne Selhorn
Aug 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document usage of !references in rules
parent
202c9728
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
doc/ci/jobs/job_control.md
doc/ci/jobs/job_control.md
+29
-0
doc/ci/yaml/index.md
doc/ci/yaml/index.md
+4
-0
No files found.
doc/ci/jobs/job_control.md
View file @
d6b63b7b
...
@@ -290,6 +290,35 @@ You can use the `$` character for both variables and paths. For example, if the
...
@@ -290,6 +290,35 @@ You can use the `$` character for both variables and paths. For example, if the
`$DOCKERFILES_DIR`
variable exists, its value is used. If it does not exist, the
`$DOCKERFILES_DIR`
variable exists, its value is used. If it does not exist, the
`$`
is interpreted as being part of a path.
`$`
is interpreted as being part of a path.
## Reuse rules in different jobs
> [Introduced in](https://gitlab.com/gitlab-org/gitlab/-/issues/322992) GitLab 14.3.
Use
[
`!reference` tags
](
../yaml/index.md#reference-tags
)
to reuse rules in different
jobs. You can combine
`!reference`
rules with regular job-defined rules:
```
yaml
.default_rules
:
rules
:
-
if
:
$CI_PIPELINE_SOURCE == "schedule"
when
:
never
-
if
:
$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
job1
:
rules
:
-
!reference
[
.default_rules
,
rules
]
script
:
-
echo "This job runs for the default branch, but not schedules."
job2
:
rules
:
-
!reference
[
.default_rules
,
rules
]
-
if
:
$CI_PIPELINE_SOURCE == "merge_request_event"
script
:
-
echo "This job runs for the default branch, but not schedules."
-
echo "It also runs for merge requests."
```
## Specify when jobs run with `only` and `except`
## Specify when jobs run with `only` and `except`
You can use
[
`only`
](
../yaml/index.md#only--except
)
and
[
`except`
](
../yaml/index.md#only--except
)
You can use
[
`only`
](
../yaml/index.md#only--except
)
and
[
`except`
](
../yaml/index.md#only--except
)
...
...
doc/ci/yaml/index.md
View file @
d6b63b7b
...
@@ -1141,6 +1141,9 @@ The job is not added to the pipeline:
...
@@ -1141,6 +1141,9 @@ The job is not added to the pipeline:
-
If no rules match.
-
If no rules match.
-
If a rule matches and has
`when: never`
.
-
If a rule matches and has
`when: never`
.
You can use
[
`!reference` tags
](
#reference-tags
)
to
[
reuse `rules` configuration
](
../jobs/job_control.md#reuse-rules-in-different-jobs
)
in different jobs.
#### `rules:if`
#### `rules:if`
Use
`rules:if`
clauses to specify when to add a job to a pipeline:
Use
`rules:if`
clauses to specify when to add a job to a pipeline:
...
@@ -4765,6 +4768,7 @@ into templates.
...
@@ -4765,6 +4768,7 @@ into templates.
### `!reference` tags
### `!reference` tags
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/266173) in GitLab 13.9.
> - [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/266173) in GitLab 13.9.
> - `rules` keyword support [introduced in](https://gitlab.com/gitlab-org/gitlab/-/issues/322992) GitLab 14.3.
Use the
`!reference`
custom YAML tag to select keyword configuration from other job
Use the
`!reference`
custom YAML tag to select keyword configuration from other job
sections and reuse it in the current section. Unlike
[
YAML anchors
](
#anchors
)
, you can
sections and reuse it in the current section. Unlike
[
YAML anchors
](
#anchors
)
, you can
...
...
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