Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Share cache only within a pipeline run on the same branch

I have a gitlab-ci pipeline in the first step of which npm dependencies are downloaded. These npm packages are also required in all subsequent stages of the pipeline. That’s why I wanted to take a closer look at the topic of caching in gitlab-ci.

Is there a key that makes the cache globally available for all stages belonging to the pipeline (of a specific branch) but generates it again on the next pipeline run?

cache:
  key: $CI_COMMIT_REF_SLUG

The cache key should be unique for each pipeline run in the same branch.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use the $CI_PIPELINE_ID variable as the cache key to make the cache available for all stages belonging to the pipeline of a specific branch. Also it’s a unique identifier for each pipeline run, which makes it ideal for use as a cache key.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading