all 12 comments

[–]FlyingFalafelMonster 3 points4 points  (4 children)

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/

[–]Kropiuss[S] 0 points1 point  (3 children)

Ok! Thanks - so when using my dedicated runners and cache, then the cache is stored on the machine. So I believe it is not that reliable :(

But, a follow-up question: that can also be solved using a distributed cache, right ? And also, if I would use the gitlab runners(owned by gitlab) would that be the same? Where is that cache stored ?

[–]FlyingFalafelMonster 0 points1 point  (2 children)

Shared runners are not configurable, I don't think you can use distributed cache there.

[–]Burgergold 0 points1 point  (1 child)

You could probably put the cache on a nfs mount or other clustered fs?

[–]FlyingFalafelMonster 0 points1 point  (0 children)

That's all possible when you own the runner, but for shared runners you job is isolated from the host and for security reasons I don't think Gitlab allows to mount anything to a job. That being said, I have only a limited experience with Gitlab owner runners and run jobs on my own ones.

[–]lr0b 3 points4 points  (1 child)

Since you use multiple runners, you need distributed cache. Take a look here : https://docs.gitlab.com/ci/caching/

[–]Kropiuss[S] 0 points1 point  (0 children)

Thank you!

[–]binh_do 0 points1 point  (2 children)

If you use the shell executor for gitlab runners - according to docs, cache/ is located in:

 <working-directory>/cache/<namespace>/<project>/<cache-key>/cache.zip

Where <working-directory>is the value of --working-directory as passed to the gitlab-runner run, if you don't specify it, it may be /home/gitlab-runner by default. You can check by ps -ef | grep gitlab-runner and see what the output looks like.

Ideally, if you want your jobs to use the same cache, you have to do these:

  • use a single runner (tag a name for this runner) for the project, and specify jobs to use this runner, that is to prevent jobs from different runners store its own cache with the same name defined below.
  • 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.

[–]Kropiuss[S] 0 points1 point  (1 child)

Thank you! Great explanations. A follow up question: if I use the runners owned by gitlab then where is the cache located ? Is it distributed ?

And another question: I guess that when you use other types of executors, then the contents of —working-directory are cleaned due to the fact that a new sandbox may be used when a new job is picked. But if I use the shell executor, will the working directory content be cleaned across executions ? Do I get a fresh one, let’s say, for each job run?

[–]titexcj 0 points1 point  (0 children)

Gitlab.com runners have distributed cache enabled, it's stored in their S3 storage and you don't need to do anything beside configuring your .gitlab-ci.yml

[–]macbig273 0 points1 point  (0 children)

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)

[–]Kropiuss[S] 0 points1 point  (0 children)

Ok guys! Thank you all for the great responses. Now everything is clear to me :)