I want to cache dependencies per branch, therefore I create a text file containing the branch number
definitions:
steps:
- step: &prepare
name: prepare environment
script:
- echo ${BITBUCKET_BRANCH} > branch.txt
artifacts:
- branch.txt
But I'm unable to use branch.txt in the cache definitions. I tried this:
caches:
node-modules:
key:
files:
- branch.txt
path: node_modules/
How can I achieve this?
Hi Nathan and welcome to the community!
It is not possible to use an artifact as a cache key file. The cache key file needs to be committed in the Bitbucket Cloud repo.
Please keep in mind that even if you commit such a file in the repo, editing it during the Pipelines build will not generate a new cache. The file needs to be changed in a commit of the repo in order for the new cache to be generated. This approach has the following drawback though:
Could you please share why you are looking to cache dependencies per branch?
For node, if you specify for example the package.json file as a cache key file, and you change the dependencies in package.json in feature/a branch, then a new cache will be generated.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.