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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Clear Cache in a pipeline step

I use bitbucket caches with my builds. At the end of my build, I'd like to clear the cache and re-upload it (to cache anything additional the most recent build created).

 

I've tried using this plugin: https://bitbucket.org/atlassian/bitbucket-clear-cache/src/master/

 

However, when I get to the end of the pipeline, the cache is not re-uploaded even though it has been cleared by the plugin. The pipeline seems unaware that the plugin has cleared the cache.

 

```

pipelines:
branches:
master:
- step:
name: Build and Test
caches:
- gradle
script:
# cache hit happens in setup
- ./scripts/build-and-test.sh
# cache is cleared by plugin
- pipe: atlassian/bitbucket-clear-cache:3.0.0
variables:
BITBUCKET_USERNAME: $BITBUCKET_USERNAME
BITBUCKET_APP_PASSWORD: $BITBUCKET_APP_PASSWORD
# BUG? in teardown, pipelines doesn't re-upload the gradle cache


```

1 answer

0 votes

@Andrew Kent the pipe you are using is only clearing cache and not responsible for reuploading.

I think it would be useful to specify the cache for the pipe, you want to clear, and it will clear only specific cache you put like

CACHES: ["gradle"]

.If you clear the same cache and reupload it again, there is no sense to use clear-cache, but if you want to reupload some specific things, you just may not type this specific cache in the CACHES variable and it will not be cleared.

If you want some another thing to upload specific caches, you can write your custom pipe, because right now we did not consider this change (but will report this if it would be really needed).

Besides that, we are going to   release the pipe you're using soon, right now it is not official.

Regards, Galyna

My scenario (often) is:

 

  • Pipeline starts up. Uses gradle-cache0 to skip 70% of the build, process.
  • Pipeline builds the remaining 30% of the cache
  • Pipeline finishes

 

As a final step, I'd like re-upload the 100% built cache (so I don't have to start at 70% every time until the cache expiration period is hit).

 

I was hoping the cache-clear plugin would solve my needs, but if I clear mid-run the cache is not re-uploaded at the end of the pipeline because there was a cache hit at the start (pipeline doesn't have the smarts to realize the cache was cleared mid-run).

 

Is there any way to accomplish this?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,328 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you