summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2017-07-06 07:40:43 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2017-07-06 07:40:43 +0000
commit7f500acb5f38f0ae5d4e2d51e27b6257e0800c3d (patch)
treedb122866e3a238c8246a33bc91d5cd91cc09354d /doc
parent6afe25ef336aca40b87cede499f8b8f5928129f6 (diff)
parent35f4a00f371ae60477bdbafe9f8274c8560320cb (diff)
downloadgitlab-ce-7f500acb5f38f0ae5d4e2d51e27b6257e0800c3d.tar.gz
Merge branch '33772-readonly-gitlab-ci-cache' into 'master'
Introduce cache policies for CI jobs Closes #33772 See merge request !12483
Diffstat (limited to 'doc')
-rw-r--r--doc/ci/yaml/README.md47
1 files changed, 47 insertions, 0 deletions
diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md
index 8a0662db6fd..724843a4d56 100644
--- a/doc/ci/yaml/README.md
+++ b/doc/ci/yaml/README.md
@@ -306,6 +306,53 @@ cache:
untracked: true
```
+### cache:policy
+
+> Introduced in GitLab 9.4.
+
+The default behaviour of a caching job is to download the files at the start of
+execution, and to re-upload them at the end. This allows any changes made by the
+job to be persisted for future runs, and is known as the `pull-push` cache
+policy.
+
+If you know the job doesn't alter the cached files, you can skip the upload step
+by setting `policy: pull` in the job specification. Typically, this would be
+twinned with an ordinary cache job at an earlier stage to ensure the cache
+is updated from time to time:
+
+```yaml
+stages:
+ - setup
+ - test
+
+prepare:
+ stage: setup
+ cache:
+ key: gems
+ paths:
+ - vendor/bundle
+ script:
+ - bundle install --deployment
+
+rspec:
+ stage: test
+ cache:
+ key: gems
+ paths:
+ - vendor/bundle
+ policy: pull
+ script:
+ - bundle exec rspec ...
+```
+
+This helps to speed up job execution and reduce load on the cache server,
+especially when you have a large number of cache-using jobs executing in
+parallel.
+
+Additionally, if you have a job that unconditionally recreates the cache without
+reference to its previous contents, you can use `policy: push` in that job to
+skip the download step.
+
## Jobs
`.gitlab-ci.yml` allows you to specify an unlimited number of jobs. Each job