When I am using a cache:
1) can I specify a cache to be used by a pipeline entirely (eg: it will be automatically used by all steps)
2) if 2 steps use the same cache and step 1 makes changes to the cached data, will step 2 receive the updated cache or the cache state under which the pipeline originally started?
Thanks
Hello @Andrei Dascalu , thank you for reaching out to Community!
Caches in Bitbucket Pipelines are defined at the step level, meaning that for each step you want to use cache, you will need to define it directly in the step
pipelines:
default:
- step:
caches:
- node
script:
- npm install
There's not currently a global option to enable cache for all the steps.
As for your second question, just bring some context on how Bitbucket pipeline caches work, when you define a cache in Bitbucket pipeline, it will generate a cache the first time the build is successful.
Once the cache is generated, it will be available for the next 7 days. During that 7-day period, any new build you trigger will download the previously generated cache during the Build Setup phase.
After 7 days, the cache will be automatically deleted, and a new fresh cache will be generated in the following successful build. You can expedite the cache refresh by manually deleting the cache in the Pipelines page > Cache button in the top right > click on the trash icon.
Another option is to use smart caches, also known as caching with file-based cache-keys , where the cache will be automatically refreshed based on the file(s) in the repository that is(are) defined as the key. Any changes to those key file(s) would result in a new cache.
You can also find more details about pipeline caches in the following article :
Hope that helps! Let me know in case you have any questions.
Thank you, @Andrei Dascalu !
Patrik S
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.