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):
bitbucketStatusNotify( buildState: 'STOPPED',
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:
- <do something>
- sleep 10 (to give me a chance to find the Stop button)
- <do something else>
- BUILD_STATUS_STRING="Notice from $BITBUCKET_REPO_FULL_NAME - Build Number $BITBUCKET_BUILD_NUMBER has ";
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
- echo $BUILD_STATUS_STRING
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 https://jira.atlassian.com/browse/BCLOUD-19866. 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 https://confluence.atlassian.com/support/implementation-of-new-features-policy-201294576.html and any updates will be posted in the feature request.
Please feel free to let me know if you have any questions.
Hi everyone, The Cloud team recently announced 12 new DevOps features that help developers ship better code, faster ! While we’re all excited about the new improvements to Bitbucket ...
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