Commit eb235193 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Fix cache:key documentation for the default value

* Re-apply changes from https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9666
* Update the wordings accordingly for the current revision
* Update the example to make it less confusing
parent 97dda379
...@@ -738,10 +738,15 @@ cache: ...@@ -738,10 +738,15 @@ cache:
rspec: rspec:
script: test script: test
cache: cache:
key: rspec
paths: paths:
- binaries/ - binaries/
``` ```
Note that since cache is shared between jobs, if you're using different
paths for different jobs, you should also set a different **cache:key**
otherwise cache content can be overwritten.
### `cache:key` ### `cache:key`
> Introduced in GitLab Runner v1.0.0. > Introduced in GitLab Runner v1.0.0.
...@@ -756,10 +761,9 @@ or any other way that fits your workflow. This way, you can fine tune caching, ...@@ -756,10 +761,9 @@ or any other way that fits your workflow. This way, you can fine tune caching,
allowing you to cache data between different jobs or even different branches. allowing you to cache data between different jobs or even different branches.
The `cache:key` variable can use any of the The `cache:key` variable can use any of the
[predefined variables](../variables/README.md), and the default key, if not set, [predefined variables](../variables/README.md), and the default key, if not
is `$CI_JOB_NAME-$CI_COMMIT_REF_NAME` which translates as "per-job and set, is just literal `default` which means everything is shared between each
per-branch". It is the default across the project, therefore everything is pipelines and jobs by default, starting from GitLab 9.0.
shared between pipelines and jobs running on the same branch by default.
NOTE: **Note:** NOTE: **Note:**
The `cache:key` variable cannot contain the `/` character, or the equivalent The `cache:key` variable cannot contain the `/` character, or the equivalent
...@@ -779,7 +783,7 @@ If you use **Windows Batch** to run your shell scripts you need to replace ...@@ -779,7 +783,7 @@ If you use **Windows Batch** to run your shell scripts you need to replace
```yaml ```yaml
cache: cache:
key: "%CI_JOB_STAGE%-%CI_COMMIT_REF_SLUG%" key: "%CI_COMMIT_REF_SLUG%"
paths: paths:
- binaries/ - binaries/
``` ```
...@@ -789,7 +793,7 @@ If you use **Windows PowerShell** to run your shell scripts you need to replace ...@@ -789,7 +793,7 @@ If you use **Windows PowerShell** to run your shell scripts you need to replace
```yaml ```yaml
cache: cache:
key: "$env:CI_JOB_STAGE-$env:CI_COMMIT_REF_SLUG" key: "$env:CI_COMMIT_REF_SLUG"
paths: paths:
- binaries/ - binaries/
``` ```
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment