Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can a cache be used instead of artefacts?

Andrei Dascalu
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!
October 10, 2023

When I am using a cache:

 

1) can I specify a cache to be used by a pipeline entirely (eg: it will be automatically used by all steps)

2) if 2 steps use the same cache and step 1 makes changes to the cached data, will step 2 receive the updated cache or the cache state under which the pipeline originally started?

 

Thanks

1 answer

1 vote
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 12, 2023

Hello @Andrei Dascalu , thank you for reaching out to Community!

Caches in Bitbucket Pipelines are defined at the step level, meaning that for each step you want to use cache, you will need to define it directly in the step 

pipelines:
  default:
    - step:
        caches:
          - node
        script:
          - npm install

There's not currently a global option to enable cache for all the steps.

As for your second question, just bring some context on how Bitbucket pipeline caches work, when you define a cache in Bitbucket pipeline, it will generate a cache the first time the build is successful.

Once the cache is generated, it will be available for the next 7 days. During that 7-day period, any new build you trigger will download the previously generated cache during the Build Setup phase.

After 7 days, the cache will be automatically deleted, and a new fresh cache will be generated in the following successful build. You can expedite the cache refresh by manually deleting the cache in the Pipelines page > Cache button in the top right > click on the trash icon.

Another option is to use smart caches, also known as caching with file-based cache-keys , where the cache will be automatically refreshed based on the file(s) in the repository that is(are) defined as the key. Any changes to those key file(s) would result in a new cache.

You can also find more details about pipeline caches in the following article :

Hope that helps! Let me know in case you have any questions.

Thank you, @Andrei Dascalu !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events