diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-07-06 07:40:43 +0000 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-07-06 07:40:43 +0000 |
commit | 7f500acb5f38f0ae5d4e2d51e27b6257e0800c3d (patch) | |
tree | db122866e3a238c8246a33bc91d5cd91cc09354d /doc/ci | |
parent | 6afe25ef336aca40b87cede499f8b8f5928129f6 (diff) | |
parent | 35f4a00f371ae60477bdbafe9f8274c8560320cb (diff) | |
download | gitlab-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/ci')
-rw-r--r-- | doc/ci/yaml/README.md | 47 |
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 |