You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.