Skip to content

Fallback cache keys

What does this MR do?

Add support for specifying multiple fallback keys on the cache block in the GitLab CI with the new field cache:fallback_keys

Runner implementation: gitlab-runner!3875 (merged)

How to set up and validate locally

In the default section:

cache: &global_cache
  key: gems-$CI_COMMIT_REF_SLUG
  paths:
    - vendor/
  fallback_keys:
    - gems

jobx:
  script: ls
  cache:
    # inherit all global cache settings
    <<: *global_cache

Using fallback_keys per job cache:

multiple_fallback_caches:
  script:
    - echo
  cache:
    key: bin-"$CI_COMMIT_REF_SLUG"
    paths:
      - binaries/
    fallback_keys:
      - bin

Related issues

Fix #22213 (closed) and #361235 (closed)

Checklist

Pre-merge

Consider the effect of the changes in this merge request on the following:

No effect

If new jobs are added:

This will help keep track of expected cost increases to the GitLab project average pipeline cost per merge request RPI

No jobs added

Post-merge

Edited by Pedro Pombeiro

Merge request reports