Im a bit confused about bitbucket pipelines cache.
Im using predefined cache:
caches:
- maven: .m2
And each time when I run maven command and I use defined cache, bitbucket says that it is importing cache and extracting it, but pipelines step still fetches dependency from web.
Why does it happen?
Hello @Filip Baszak and thank you for reaching out to Community!
When using a pre-defined cache, you don't need to specify the folder to cache, as Bitbucket Pipelines will get them from the default location used by that framework/took. For Maven, you should define the cache as follows:
caches:
- maven
This would cache dependencies that maven saves in the directory ~/.m2/repository. You can check other available pre-defined caches and their respective directories in our Cache Dependencies documentation.
The way that cache works is that the first time you run the build after adding the cache to your YML, the dependencies will be downloaded from the internet, and at the end of the step, all dependencies in the cache directory will be compressed and saved by Bitbucket. In the subsequent builds, at the start of the step bitbucket will download the previously generated cache and extract it to the same directory they were originally generated. The cache lasts for 7 days. After that period, the following build will again download the dependencies from the internet, which will generate a new cache that will last another 7 days, and so on.
You can find more details and learn more about limitations of caches in the following documentation :
Should you have any questions, feel free to ask!
Thank you, @Filip Baszak !
Patrik S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.