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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,555,496
Community Members
 
Community Events
184
Community Groups

Using artifact as cache key file

Nathan Taal
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 15, 2023

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?

1 answer

0 votes
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,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events