If I have two consecutive steps using the same cache, for example, `pip`. Will the caches be merged? Is it possible to merge the same cache from multiple steps?
G'day, @Ian Liu Rodrigues
I believe merging the same cache from multiple steps is impossible as the cache is created when steps succeed. However, you might want to look into the Smart caches that we just released last year:
Announcing smarter caches in Bitbucket Pipelines
Cache keys provide a way to uniquely identify versions of a cache based on a set of files in your repository. The typical use case would be to define a cache key based on files that define a project's dependencies. When dependencies are updated, the hash of the key files also updates and Pipelines will be able to generate a unique cache version for subsequent builds. As multiple cache versions are able to be retained, future builds using either the old or new dependency set will have a unique cache version to reuse.
I hope this helps.
Regards,
Syahrul
Hi @Syahrul , thanks for the reply!
I've read the documentation page you've linked, and I think it wouldn't solve this issue.
I guess the best term here isn't "merging caches", but a "global cache", that is updated on every step if the contents of the cache directory changes between steps.
For example, consider the following scenario:
Step 1 only installs linting tools, so the pipeline fails as fast as possible in case of a lint error, and caches the pip packages to speedup even further.
Step 2 installs build dependencies, which also caches in the pip cache, but this will not work because now the cache only contains the linting tools. I think Smart caches can't solve this either, since my requirements.txt file didn't change here.
I guess I could define multiple caches for each step, but this gets really cumbersome, and the same packages would be cached multiple times.
To overcome this difficulty, all my bitbucket pipelines are now a single step.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.