I have a node_modules cache in my Bibucket Pipeline and I added new module (eg yarn add react-modal) - how to make Bitbucket pipelines detect new yarn.lock and invalidate its cache?
Yeah, as Marecky have already mentioned, there is a ticket for that. Also, there is another one here https://jira.atlassian.com/browse/BCLOUD-17605, which should exactly address the issue. In short, there is an API to invalidate the cache, but it's currently reserved for internal use only.
Here is the official way to clear the caches
https://bitbucket.org/atlassian/bitbucket-clear-cache/src/master/
Since early 2023, they way to go for the use-case of invalidating a cache on some lockfile changes would be to use the new cache keys feature.
definitions:
caches:
node:
key:
- yarn.lock
path: ...
See
Note that the slightest change in the key files will discard the previous cache. This might be sensible in some scenarios but the previous cache might still feature a 99% hit rate, e.g. when adding or updating a single dependency. So, use this if it actually speeds up your use-case and keep in mind that caches are weekly cleared anyway.
© 2022 - 2024 — McMap. All rights reserved.
npm install --dryrun
to your scripts and break the pipeline if its output does not containup to date in
– Bomke