Bamboo - cancel deployment actions

We have deployment plans (NOT BUILD PLANS!) that a user may want to cancel for whatever reason.  When the user presses the cancel button, there doesn't appear any way to capture that fact during the Deployment process.  We'd like to then do something after a user cancels a deployment.  For background, we have a custom-made deployment mechanism that handles deployments asynchronously.  Namely:

  1. Send Deployment product to server
  2. Poll server endpoing to see when deployment is "done"
  3. Report success/failure

The problem is that if the end user clicks, in Bamboo, "cancel", we'd like to then send a "cancel deployment" command to the deployment mechanism (simple REST call does the trick).  However, I can't seem to find anything like "final" tasks in the Deployment stack, or any variables that suggest that the deployment was manually cancelled.  Is there a way to capture that some how?  I can't figure out what Bamboo does to the active running tasks on the Deployment side (issue a kill -N signal that I could trap in a script?) when you cancel an active deployment.

Note - this is for DEPLOYMENT PLANS, not BUILD PLANS.

1 answer

This widget could not be displayed.

Hi Jon,

In a deployment project you should see a line that says Final Tasks and you can drag items under the Final Task to make sure they run even if the other tasks failed:

Screen Shot 2017-07-18 at 1.43.50 PM.png

 

In regards to who completed the plan, if you view the full deployment log, you can search for "Request to Stop."

Cheers,

Branden

OK, but how would I use that programmatically?  I can always manually observe a log file to see if "Request to Stop" happened.  Are you saying that I should create some kind of parser that runs that does a grep on the output log (wherever it's stored locally) for a given deployment, and then execute on that?  I can't find a "parse deployment log file" task.

Hrm.  It appears that I can (probably fragile-ly) construct a path to grep in a log from:

#!/bin/bash

BASE=/path/to/bamboo-home/xml-data/builds
BUILD_DIR_BASE=$(echo $bamboo_working_directory | awk -F / '{printf $NF}')
BUILD_LOG_BASE=$(echo $bamboo_resultsUrl | awk -F = '{print $NF}')
BUILD_LOG=${BASE}/${BUILD_DIR_BASE}/download-data/build_logs/${BUILD_DIR_BASE}-${BUILD_LOG_BASE}.log

if grep -E -q "command.*Request to stop.*${BUILD_DIR_BASE}-${BUILD_LOG_BASE}" ${BUILD_LOG} ; then
echo "doing some additional action based on user requesting a stop"
else
echo "Nothing to do, happy enjoying!"
fi

Is that what's expected?  I didn't see any values that pointed to the existing build log (like a $bamboo_build_log) set in any of the deployment log.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

201 views 1 3
Join discussion

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you