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/yaml
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-03-11 15:39:11 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2016-03-11 15:41:05 +0300
commitad4d3a075fc338280baaf6240861c9de7aa312ad (patch)
tree14c99f23fa5a85686f3b5be1b5160a5ff45ce657 /doc/ci/yaml
parent0c5b92cbd7afe7483470c7d33a0b8475ba91d390 (diff)
Describe special YAML features: the use of anchors and hidden jobs
Diffstat (limited to 'doc/ci/yaml')
-rw-r--r--doc/ci/yaml/README.md71
1 files changed, 71 insertions, 0 deletions
diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md
index 051eaa04152..ec57ac5789e 100644
--- a/doc/ci/yaml/README.md
+++ b/doc/ci/yaml/README.md
@@ -509,6 +509,77 @@ rspec:
The cache is provided on best effort basis, so don't expect that cache will be
always present. For implementation details please check GitLab Runner.
+## Special features
+
+It's possible special YAML features like anchors and map merging.
+Thus allowing to greatly reduce the complexity of `.gitlab-ci.yml`.
+
+#### Anchors
+
+You can read more about YAML features [here](https://learnxinyminutes.com/docs/yaml/).
+
+```yaml
+.job_template: &job_definition
+ image: ruby:2.1
+ services:
+ - postgres
+ - redis
+
+test1:
+ << *job_definition
+ script:
+ - test project
+
+test2:
+ << *job_definition
+ script:
+ - test project
+```
+
+The above example uses anchors and map merging.
+It will create a two jobs: `test1` and `test2` that will have the parameters of `.job_template` and custom `script` defined.
+
+```yaml
+.job_template: &job_definition
+ script:
+ - test project
+
+.postgres_services:
+ services: &postgres_definition
+ - postgres
+ - ruby
+
+.mysql_services:
+ services: &mysql_definition
+ - mysql
+ - ruby
+
+test:postgres:
+ << *job_definition
+ services: *postgres_definition
+
+test:mysql:
+ << *job_definition
+ services: *mysql_definition
+```
+
+The above example uses anchors to define two set of services.
+It will create a two jobs: `test:postgres` and `test:mysql` that will have the script defined in `.job_template`
+and one, the service defined in `.postgres_services` and second the services defined in `.mysql_services`.
+
+### Hidden jobs
+
+The jobs that start with `.` will be not processed by GitLab.
+
+Example of such hidden jobs:
+```yaml
+.job_name:
+ script:
+ - rake spec
+```
+
+The `.job_name` will be ignored. You can use this feature to ignore jobs, or use them as templates with special YAML features.
+
## Validate the .gitlab-ci.yml
Each instance of GitLab CI has an embedded debug tool called Lint.