Clearing the pipeline cache with Gitlab CI
Artifacts are the solution as mentioned in the comments. However there is an option to clear caches in the Pipelines page as shown in the image below.
It's not a perfect solution, but we ended up creating a cleanup job at the end of our .gitlab-ci.yaml
file that deletes the cache directory from the filesystem.
This way, each pipeline gets its own unique cache, without cluttering up the file system over time.
cleanup_job:
stage: cleanup
script:
- echo "Cleaning up"
- rm -rf "%CACHE_PATH%/%CI_PIPELINE_ID%"
when: always
where
CACHE_PATH: "C:/gitlab-runner/cache/group/project/repo/"
Quote from @ayufan one of the project masters of Gitlab:
The cache is stored in
/home/gitlab-runner/cache
or as docker containerdocker ps | grep -cache-
.
There fore you can try to delete the directory and purge all returned docker containers.