Granular abort on fail

Sometimes I am asked how to abort a release when a task fails. A property of a template is Abort on failure checkbox. This ensures that should a failure occur the release will be aborted. Done.

Well, not quite, sometimes you may not want this behaviour (e.g. a slack notification failing shouldn’t necessarily undo all good work done to date) . Enter the Failure handler.

For those tasks that you want to kill a release without hesitation (e.g. failing deployments, tests etc) you can add a line to your enabled Failure Handler

Just remember to update your template Run Automated Tasks as User property

:wink:

3 Likes

Hi Rob,
in my case when a given task failed i whish i could do a couple of other tasks (update a jira status, notify a user) and then abort.
About doing a couple of other tasks after the failure i did it with automatically skipping the failed task (thanks to Failure Handler). But once i completed my other tasks (update jira status, notify a user) i now want to abort my release. I plan to do it from a jython script task. The jython code seems easy:

curRelease = getCurrentRelease()
releaseApi.abort(curRelease.id, “Aborting the release”)

but… it fails with the following error message :

“The release xxxx could not be aborted because it has automated tasks that are in progress”

I am afraid the automated task the error is talking of is precisely the jython script task from where i am trying to abort the release…
Any idea about how to bypass this ?

Many thanks.
With Regards

Just in case i found a workaround… my last jython task (the one supposed to abort the release, here a jython task but could be another task type which i would ensure i will fail) is now only doing a “sys.exit(1)” and in the failure handler of this jython task i put these 2 lines :

curRelease = getCurrentRelease()
releaseApi.abort(curRelease.id, “Aborting the release”)

Not very clean but it works… I you have in mind any other way to proceed i am interested!
Thanks

thanks my issue has been fixed.