Commit 776d2ac1 authored by King Chung Huang's avatar King Chung Huang Committed by Dylan Griffith

Describe recursive merging in ci/yaml docs

Rework the section about include in the ci/yaml docs to describe
recursive merges. Also add a note that in prior releases of GitLab, the
.gitlab-ci.yml took strict precedence over includes.
parent d68f43bd
...@@ -1276,10 +1276,17 @@ include: ...@@ -1276,10 +1276,17 @@ include:
--- ---
Since external files defined by `include` are evaluated first, the content of Files defined by `include` are always evaluated first and recursively merged
`.gitlab-ci.yml` will always take precedence over the content of the external with the content of `.gitlab-ci.yml`, no matter the position of the `include`
files, no matter of the position of the `include` keyword. This allows you to keyword. You can take advantage of recursive merging to customize and override
override values and functions with local definitions. For example: details in included CI configurations with local defintions.
NOTE: **Note:**
Before GitLab 10.8, the content of `.gitlab-ci.yml` always took precedence
over the content of external files.
The following example shows specific YAML-defined variables and details of
the `production` job from an include file being customized in `.gitlab-ci.yml`.
```yaml ```yaml
# Content of https://company.com/autodevops-template.yml # Content of https://company.com/autodevops-template.yml
...@@ -1311,7 +1318,6 @@ image: alpine:latest ...@@ -1311,7 +1318,6 @@ image: alpine:latest
variables: variables:
POSTGRES_USER: root POSTGRES_USER: root
POSTGRES_PASSWORD: secure_password POSTGRES_PASSWORD: secure_password
POSTGRES_DB: company_database
stages: stages:
- build - build
...@@ -1319,20 +1325,13 @@ stages: ...@@ -1319,20 +1325,13 @@ stages:
- production - production
production: production:
stage: production
script:
- install_dependencies
- deploy
environment: environment:
name: production
url: https://domain.com url: https://domain.com
only:
- master
``` ```
In this case, the variables `POSTGRES_USER`, `POSTGRES_PASSWORD` and In this case, the variables `POSTGRES_USER` and `POSTGRES_PASSWORD` along
`POSTGRES_DB` along with the `production` job defined in with the environment url of the `production` job defined in
`autodevops-template.yml` will be overridden by the ones defined in `autodevops-template.yml` have been overridden by new values defined in
`.gitlab-ci.yml`. `.gitlab-ci.yml`.
NOTE: **Note:** NOTE: **Note:**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment