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
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-10-15 16:08:31 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2015-10-16 00:49:39 +0300
commit0aa6061d6ab0ab921ad585329b43b84d20da873e (patch)
tree85ffa24aa303fa5d345c34b8810674ee493edc43 /doc/ci
parent3d763907986c64cd14ced1ed7a4cfab1641abea2 (diff)
Implement when syntax in .gitlab-ci.yml
Diffstat (limited to 'doc/ci')
-rw-r--r--doc/ci/yaml/README.md49
1 files changed, 49 insertions, 0 deletions
diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md
index 4caeccacb7f..8507389f1ce 100644
--- a/doc/ci/yaml/README.md
+++ b/doc/ci/yaml/README.md
@@ -140,6 +140,7 @@ job_name:
| except | optional | Defines a list of git refs for which build is not created |
| tags | optional | Defines a list of tags which are used to select runner |
| allow_failure | optional | Allow build to fail. Failed build doesn't contribute to commit status |
+| when | optional | Define when to run build. Can be on_success, on_failure or always |
### script
`script` is a shell script which is executed by runner. The shell script is prepended with `before_script`.
@@ -196,6 +197,54 @@ job:
The above specification will make sure that `job` is built by a runner that have `ruby` AND `postgres` tags defined.
+### when
+`when` is used to implement jobs that are run in case of failure or despite the failure.
+
+The `when` can be set to one of the following values:
+1. `on_success` - execute build only when all builds from prior stages succeeded. This is default.
+1. `on_failure` - execute build only when at least one of the build from prior stages failed.
+1. `always` - execute build despite the status of builds from prior stages.
+
+```
+stages:
+- build
+- cleanup_build
+- test
+- deploy
+- cleanup
+
+build:
+ stage: build
+ script:
+ - make build
+
+cleanup_build:
+ stage: cleanup_build
+ script:
+ - cleanup build when failed
+ when: on_failure
+
+test:
+ stage: test
+ script:
+ - make test
+
+deploy:
+ stage: deploy
+ script:
+ - make deploy
+
+cleanup:
+ stage: cleanup
+ script:
+ - cleanup after builds
+ when: always
+```
+
+The above script will:
+1. Execute `cleanup_build` only when the `build` failed,
+2. Always execute `cleanup` as the last step in pipeline.
+
## Validate the .gitlab-ci.yml
Each instance of GitLab CI has an embedded debug tool called Lint.
You can find the link to the Lint in the project's settings page or use short url `/lint`.