diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-15 21:10:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-15 21:10:04 +0300 |
commit | 5ff1f808adf841bca979cb2fac6bdfa9c449d028 (patch) | |
tree | c95cfbbcb400684b2bc89fee4fc7b614315ba909 /doc/ci | |
parent | f8a5275c45ed2276daf843764113476749e680d2 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'doc/ci')
-rw-r--r-- | doc/ci/caching/index.md | 41 | ||||
-rw-r--r-- | doc/ci/yaml/index.md | 27 |
2 files changed, 65 insertions, 3 deletions
diff --git a/doc/ci/caching/index.md b/doc/ci/caching/index.md index b87f34aa633..e9d3dae3837 100644 --- a/doc/ci/caching/index.md +++ b/doc/ci/caching/index.md @@ -91,10 +91,37 @@ test-job: ``` If multiple caches are combined with a fallback cache key, -the fallback cache is fetched every time a cache is not found. +the global fallback cache is fetched every time a cache is not found. ## Use a fallback cache key +### Per-cache fallback keys + +> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/110467) in GitLab 16.0 + +Each cache entry supports up-to 5 fallback keys: + +```yaml +test-job: + stage: build + cache: + - key: cache-$CI_COMMIT_REF_SLUG + fallback_keys: + - cache-$CI_DEFAULT_BRANCH + - cache-default + paths: + - vendor/ruby + script: + - bundle config set --local path 'vendor/ruby' + - bundle install + - yarn install --cache-folder .yarn-cache + - echo Run tests... +``` + +Fallback keys follows the same processing logic as `cache:key`, meaning that the fullname may include a `-$index` (based on cache clearance) and `-protected`/`-non_protected` (if cache separation enabled on protected branches) suffixes. + +### Global fallback key + > [Introduced](https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/1534) in GitLab Runner 13.4. You can use the `$CI_COMMIT_REF_SLUG` [predefined variable](../variables/predefined_variables.md) @@ -120,6 +147,14 @@ job1: - binaries/ ``` +The order of caches extraction is: + +1. Retrieval attempt for `cache:key` +1. Retrieval attemps for each entry in order in `fallback_keys` +1. Retrieval attempt for the global fallback key in `CACHE_FALLBACK_KEY` + +The cache extraction process stops after the first successful cache is retrieved. + ## Disable cache for specific jobs If you define the cache globally, each job uses the @@ -623,10 +658,10 @@ job B: ``` 1. `job A` runs. -1. `public/` is cached as cache.zip. +1. `public/` is cached as `cache.zip`. 1. `job B` runs. 1. The previous cache, if any, is unzipped. -1. `vendor/` is cached as cache.zip and overwrites the previous one. +1. `vendor/` is cached as `cache.zip` and overwrites the previous one. 1. The next time `job A` runs it uses the cache of `job B` which is different and thus isn't effective. diff --git a/doc/ci/yaml/index.md b/doc/ci/yaml/index.md index 49dbd08c90b..ab5226c1c30 100644 --- a/doc/ci/yaml/index.md +++ b/doc/ci/yaml/index.md @@ -1480,6 +1480,33 @@ faster-test-job: - echo "Running tests..." ``` +#### `cache:fallback_keys` + +Use `cache:fallback_keys` to specify a list of keys to try to restore cache from +if there is no cache found for the `cache:key`. Caches are retrieved in the order specified +in the `fallback_keys` section. + +**Keyword type**: Job keyword. You can use it only as part of a job or in the +[`default` section](#default). + +**Possible inputs**: + +- An array of cache keys + +**Example of `cache:fallback_keys`**: + +```yaml +rspec: + script: rspec + cache: + key: gems-$CI_COMMIT_REF_SLUG + paths: + - rspec/ + fallback_keys: + - gems + when: 'always' +``` + ### `coverage` Use `coverage` with a custom regular expression to configure how code coverage |