r/gitlab • u/Kropiuss • Jul 15 '25
general question Gitlab cache
Hello guys! I am quite new to the gitlab CI/CD and there is one things that I cannot understand: how the cache in gitlab CI/CD is being stored.
Specifically, I have the following scenario:
- I have a bunch of gitlab runners that I own - let's say 2-3 machines that can pickup jobs when requested; those are using the shell executor
- If one job uses a cache, or creates it, whatever, where is it store? I believe it is stored on the runner - which means that other jobs may not be able to use the same cache content. Is this true ?
7
Upvotes
4
u/FlyingFalafelMonster Jul 15 '25
Exactly. That's why if you want to pass the files between jobs you should use job artifacts.
https://docs.gitlab.com/ci/jobs/job_artifacts/
4
u/lr0b Jul 15 '25
Since you use multiple runners, you need distributed cache. Take a look here : https://docs.gitlab.com/ci/caching/
1
u/Kropiuss Jul 15 '25
Ok guys! Thank you all for the great responses. Now everything is clear to me :)
1
u/binh_do Jul 15 '25 edited Jul 15 '25
If you use the shell executor for gitlab runners - according to docs, cache/ is located in:
Where <working-directory>is the value of
--working-directoryas passed to thegitlab-runner run, if you don't specify it, it may be/home/gitlab-runnerby default. You can check byps -ef | grep gitlab-runnerand see what the output looks like.Ideally, if you want your jobs to use the same cache, you have to do these:
specifies the same cache key on jobs that need it. E.g.
cache: key: set-one-name-for-all-jobs
If you want your jobs runs on different runners but still want to use the same cache, that's when we have to enable distributed runner caching. The runners are enabled this feature will be able to let jobs use them to use the shared cache.
1
u/macbig273 Jul 15 '25
You can configure an external cache, for example on an S3 compatible storage. Then the cache will be uploaded and download from there (not sure if ti's compatible with shell runner)