Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
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

How do I capture it when a Bitbucket Pipeline is manually stopped?

Here's what I have working in Jenkins: I use an add-on called Bitbucket Status Notifier that can look for three conditions - success, failure, and cancellation of a job - and send that notification to our Teams channel (I know, Teamssss, but this is my life now):

steps { 

<other attributes>)

post {
success {


<other attributes>)


failure {


<other attributes>)

aborted {
bitbucketStatusNotify( buildState: 'STOPPED',
<other attributes>)

In Pipelines, I can capture the exit code of successes and failures using the BITBUCKET_EXIT_CODE variable, but I can't seem to figure out how to capture it when I manually cancel a job while it's running. Here's what I have so far:

- step: 
name: MyStep
- <do something>
- sleep 10 (to give me a chance to find the Stop button)
- <do something else>
- |
if [ "$BITBUCKET_EXIT_CODE" == "0" ]; then
elif [ "$BITBUCKET_EXIT_CODE" == "1" ]; then
# this next condition is where it doesn't work
elif [ -z "$BITBUCKET_EXIT_CODE" ]; then
BUILD_STATUS_STRING+="been cancelled manually";

# here is where i normally curl the webhook, but let's just echo it for now


1 answer

1 accepted

0 votes
Answer accepted

Hi @inger_klekacz ,

I'm not sure about the value of $BITBUCKET_EXIT_CODE when a build is manually stopped. However, the after-script runs only when a step succeeds or fails. If the build is stopped, the after-script won't run, which basically doesn't make possible to capture this use case there.

That would be dependant on the implementation of If you'd be interested in this, I would suggest to add your vote in the feature request (by selecting the Vote for this issue link) as the number of votes helps the development team and product managers better understand the demand for new features. You are more than welcome to leave any feedback, and you can also add yourself as a watcher (by selecting the Start watching this issue link) if you'd like to get notified via email on updates.

Implementation of new features is done as per our policy here and any updates will be posted in the feature request.

Please feel free to let me know if you have any questions.

Kind regards,

Thanks for this information! I've upvoted and commented upon the request.

Like Theodora Boudale likes this

Suggest an answer

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

📣 Calling Bitbucket Data Center customers to participate in research

Hi everyone, Are you Bitbucket DC customer? If so, we'd love to talk to you! Our team wants to dive deep to understand your long-term plans regarding Bitbucket DC and Atlassian Cloud. Do you plan...

118 views 2 4
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