Skip to content

Per-job cache should fallback to global defaults

I apologize in advance if this issue is better suited for the Gitlab CE project

Let's say that I have a .gitlab.ci.yml file that configures a global cache and some jobs that configure their own local cache. I would expect that the local cache variables will override the global cache variables. Any variables that are not defined will fallback to what's defined at the global level.

For example, I want all my jobs to use the same cache key and paths. Most jobs will use the pull policy, but I will have one single job utilizing the pull-push strategy. Here's example partial configuration (ignore missing mandatory attributes besides in the cache element):

cache:
  key: "$CI_PROJECT_PATH"
  policy: pull
  paths:
    - node_modules

stages:
  - test

test:
  stage: test
  cache:
    policy: pull-push

I expected the test job to use all my global cache setting, with the only difference that it will push the cache to S3 at the end of the build. Instead, the global variables are ignored and no cache is pulled.

I highly encourage that Gitlab Runner supports fallback to global configuration for partially configured job-level cache elements. This is what I expect to happen based on my experience with many other systems that support global- and local-level configuration, overrides and fallbacks. Regardless of what approach is chosen, please also make sure that documentation is made more clear around this particular case.