How to disable GitLab build caching for a job
Asked Answered
A

2

7

In GitLab there seem to be some sort of build cache.

For example, I have a job which builds and tags a docker image. The job succeeds and build log looks normal, but the image isn't actually created in the runner. Same thing with files: writing to file, which doesn't exist after job finishes. I suspect the build uses some kind of cache, as it executes so fast in these scenarios.

This behavior seems to manifest most often with detached pipelines, tag pipelines and when pipelines points to same commit via different refs in general.

How do I disable job caching and force the side effects to happen?

Affer answered 7/4, 2021 at 6:12 Comment(0)
E
20

According to GitLab's documentation on caching you can try:

job_name:
  cache: []
  ...
Eggplant answered 5/6, 2021 at 16:10 Comment(5)
Now the document changed to: job: cache: []Cowled
Indeed it should be cache: []Arcadian
cache config should be a hashShanta
The documentation is wrong, you should use cache: {} which specifies an empty hash ([] is an empty list).Deviationism
in 2023, and gitlab 16, cache: {} doesn't work, cache: [] does work. documentation was changed here: gitlab.com/gitlab-org/gitlab/-/merge_requests/67881Bellringer
S
1

In config.toml file use the following configuration parameter :

[runners.docker]
...
disable_cache = true
...
Sneed answered 9/1, 2024 at 8:28 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.