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
b3c5e4e5
Commit
b3c5e4e5
authored
Jul 02, 2020
by
Ben Bodenmiller
Committed by
Evan Read
Jul 02, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide merging details and example for YAML Anchors
parent
8a26748d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
doc/ci/yaml/README.md
doc/ci/yaml/README.md
+15
-1
No files found.
doc/ci/yaml/README.md
View file @
b3c5e4e5
...
...
@@ -4156,7 +4156,8 @@ Read more about the various [YAML features](https://learnxinyminutes.com/docs/ya
YAML has a handy feature called 'anchors', which lets you easily duplicate
content across your document. Anchors can be used to duplicate/inherit
properties, and is a perfect example to be used with
[
hidden jobs
](
#hide-jobs
)
to provide templates for your jobs.
to provide templates for your jobs. When there is duplicate keys, GitLab will
perform a reverse deep merge based on the keys.
The following example uses anchors and map merging. It will create two jobs,
`test1`
and
`test2`
, that will inherit the parameters of
`.job_template`
, each
...
...
@@ -4217,6 +4218,8 @@ directive defined in `.postgres_services` and `.mysql_services` respectively:
.job_template
:
&job_definition
script
:
-
test project
tags
:
-
dev
.postgres_services
:
services
:
&postgres_definition
...
...
@@ -4231,6 +4234,8 @@ directive defined in `.postgres_services` and `.mysql_services` respectively:
test:postgres:
<<
:
*job_definition
services
:
*postgres_definition
tags
:
-
postgres
test:mysql:
<<
:
*job_definition
...
...
@@ -4243,6 +4248,8 @@ The expanded version looks like this:
.job_template
:
script
:
-
test project
tags
:
-
dev
.postgres_services
:
services
:
...
...
@@ -4260,6 +4267,8 @@ test:postgres:
services
:
-
postgres
-
ruby
tags
:
-
postgres
test:mysql:
script
:
...
...
@@ -4267,10 +4276,15 @@ test:mysql:
services
:
-
mysql
-
ruby
tags
:
-
dev
```
You can see that the hidden jobs are conveniently used as templates.
NOTE:
**Note:**
Note that
`tags: [dev]`
has been overwritten by
`tags: [postgres]`
.
NOTE:
**Note:**
You can't use YAML anchors across multiple files when leveraging the
[
`include`
](
#include
)
feature. Anchors are only valid within the file they were defined in.
...
...
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