Skip to content

Read-only cache jobs

Description

.gitlab-ci.yml includes a cache directive, which is used to retrieve and store parts of the job's filesystem on a best-effort basis. Uploading the cache can take a long time, and is unnecessary if the job makes no changes to its contents.

Proposal

Add a readonly: true (or similar) directive to the cache section in .gitlab-ci.yml, which signals that the cache should be downloaded for a particular job, but not uploaded.

This results in a saving of of both time and bandwidth. consider the pipeline for gitlab-ce:

prepare -> {50 * test } -> ...

The 50 test jobs need to download the cache, but they don't need to upload it. Any needed changes to the cache contents can be made in the prepare phase.

Documentation blurb

(Write the start of the documentation of this feature here, include:

  1. Why should someone use it; what's the underlying problem.
  2. What is the solution.
  3. How does someone use this

During implementation, this can then be copied and used as a starter for the documentation.)

Final solution

cache:
  policy: pull|push|pull-push

/cc @grzesiek

Edited by Kamil Trzciński