I want to use cache in a GitLab pipeline within only a specific pipeline, so other pipelines do not access it. I have written the example below to demonstrate what I mean. In this example, I want to see two files, dist/build and dist/test
, in the result job, but I can’t.
stages:
- Build
- Test
- Result
cache:
key: $CI_COMMIT_SHA
paths:
- dist/
build:
stage: Build
script:
- mkdir -p dist/
- touch dist/build
cache:
- key: $CI_COMMIT_SHA
test:
stage: Test
script:
- mkdir -p dist/
- touch dist/test
cache:
- key: $CI_COMMIT_SHA
result:
stage: Result
script:
- ls dist/
cache:
- key: $CI_COMMIT_SHA
Despite setting up the cache, the result job does not find the dist/
directory or the files dist/build
and dist/test
when running ls dist/
. Why can’t GitLab handle the cache in this case?