Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Using artifact as cache key file

Deleted user May 15, 2023

I want to cache dependencies per branch, therefore I create a text file containing the branch number


- step: &prepare
name: prepare environment
- echo ${BITBUCKET_BRANCH} > branch.txt
- branch.txt

But I'm unable to use branch.txt in the cache definitions. I tried this:

- branch.txt
path: node_modules/

How can I achieve this?

1 answer

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 16, 2023

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:

  • Assume you have a file branch.txt in main branch with content 'main'
  • You create a branch out of main, named feature/a
  • You edit branch.txt in feature/a and change the content into 'feature/a'
  • When you merge feature/a into main, the content of branch.txt in main will change from 'main' to 'feature/a'

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,

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events