Backend: Allow variables to be used as `cache:policy` values
In certain scenarios, we want the same job to behave differently with cache based on the conditions in which it is being run. For example, we want a job to create and push cache when it is part of a scheduled nightly pipeline. However, when it is part of an MR pipeline, we want it to just pull the cache. One possible way to do this is to set a variable using workflow:rules
and then use that variable as the value for cache:policy
.
variables:
BUILD_CACHE_POLICY: 'pull'
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
variables:
BUILD_CACHE_POLICY: 'push'
job1:
script:
- echo "Hello World"
cache:
key: 'foobar'
policy: $BUILD_CACHE_POLICY
This is a bit different than #270415 because it lets the policy to be configured per job.
Proposal
Allow variables to be used as values for cache:policy
. If the variable does not exist, fallback to push-pull
.
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.