diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-01-21 11:15:28 +0000 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-01-21 15:01:36 -0800 |
commit | e7a875cc79a9c123438e38a5feb15abea7079786 (patch) | |
tree | df2c259e825f8a9df6b60845145c7ef5a107c09e /doc | |
parent | ed54f5f4df0065e2d2eeccfd6279f2e7a3e937e2 (diff) | |
download | gitlab-ce-e7a875cc79a9c123438e38a5feb15abea7079786.tar.gz |
Merge branch 'ci/cache-key' into 'master'
Added cache:key to .gitlab-ci.yml allowing to fine tune the caching
The `cache:key` allows you to define the affinity mask of caching, allowing to have single cache for all jobs, or cache per-job, or per-branch, or any other way you would need:
1. Cache per-build for all branches:
```
cache:
key: "$CI_BUILD_NAME"
untracked: true
```
2. Cache per-branch for all jobs:
```
cache:
key: "$CI_BUILD_REF"
untracked: true
```
/cc @DouweM @grzesiek @axil
See merge request !2436
Diffstat (limited to 'doc')
-rw-r--r-- | doc/ci/yaml/README.md | 60 |
1 files changed, 56 insertions, 4 deletions
diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index fd0d49de4e4..3b594df659d 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -135,10 +135,9 @@ thus allowing to fine tune them. ### cache `cache` is used to specify a list of files and directories which should be -cached between builds. Caches are stored according to the branch/ref and the -job name. They are not currently shared between different job names or between -branches/refs, which means that caching will benefit you if you push subsequent -commits to an existing feature branch. +cached between builds. + +**By default the caching is enabled per-job and per-branch.** If `cache` is defined outside the scope of the jobs, it means it is set globally and all jobs will use its definition. @@ -152,6 +151,59 @@ cache: - binaries/ ``` +#### cache:key + +_**Note:** Introduced in GitLab Runner v1.0.0._ + +The `key` directive allows you to define the affinity of caching +between jobs, allowing to have a single cache for all jobs, +cache per-job, cache per-branch or any other way you deem proper. + +This allows you to fine tune caching, allowing you to cache data between different jobs or even different branches. +The `cache:key` variable can use any of the [predefined variables](../variables/README.md): + +Example configurations: + +To enable per-job caching: + + ```yaml + cache: + key: "$CI_BUILD_NAME" + untracked: true + ``` + +To enable per-branch caching: + + ```yaml + cache: + key: "$CI_BUILD_REF_NAME" + untracked: true + ``` + +To enable per-job and per-branch caching: + + ```yaml + cache: + key: "$CI_BUILD_NAME/$CI_BUILD_REF_NAME" + untracked: true + ``` + +To enable per-branch and per-stage caching: + + ```yaml + cache: + key: "$CI_BUILD_STAGE/$CI_BUILD_REF_NAME" + untracked: true + ``` + +If you use **Windows Batch** to run your shell scripts you need to replace the `$` with `%`: + + ```yaml + cache: + key: "%CI_BUILD_STAGE%/%CI_BUILD_REF_NAME%" + untracked: true + ``` + ## Jobs `.gitlab-ci.yml` allows you to specify an unlimited number of jobs. Each job |