Flushing the pipeline cache using Gitlab CI

Is it possible to invalidate or clear the pipeline cache using Gitlab CI after pipeline completion?

My .gitlab-ci.ymlfile has the following global cache definition

cache:
  key: "%CI_PIPELINE_ID%"
  paths:
    - './msvc/Project1`/bin/Debug'
    - './msvc/Project2`/bin/Debug'
    - './msvc/Project3`/bin/Debug'

The value cache-keyindicates that each pipeline should support its own cache, which works fine, but the cache file continues to exist after the pipeline finishes. With the launch of hundreds of pipelines, the size begins to take shape and manually deleting the cache folder on our machine is not a great solution.

I tried adding a cleaning job at the end of the pipeline

cleanup:
  stage: cleanup
  script:
  - rm -rf './msvc/Project1/bin'
  - rm -rf './msvc/Project2/bin'
  - rm -rf './msvc/Project3/bin'
  when: always

which deletes local files but does not delete them from the cache.

Am I missing something?

Gitlab-EE 10.3.3 is currently running.

+4
source share
2

, .gitlab-ci.yaml , .

, .

cleanup_job:
  stage: cleanup
  script:
    - echo "Cleaning up"
    - rm -rf "%CACHE_PATH%/%CI_PIPELINE_ID%"
  when: always

CACHE_PATH: "C:/gitlab-runner/cache/group/project/repo/"
+1

@ayufan Gitlab:

/home/gitlab-runner/cache docker ps | grep -cache-.

.

0

Source: https://habr.com/ru/post/1692789/


All Articles