6

This seems so trivial, I am almost shy to ask... Depending on certain conditions, which I am able to check by looking at Bamboo variables, I sometimes want to just stop the execution of a build and/or it's deploy. The possibility to conditionally execute steps seems very limited in Bamboo, and I am having trouble solving this. I found a workaround, which is running a script that exits with an error, like a powershell script simple as this

exit 1

But that obviously causes the build to appear as failed, which really isn't what I want. I just want to prevent a deploy in certain conditions.

Does anyone know an elegant way to accomplish a full stop in a Bamboo plan?

9
  • 1
    What about exit 0 ?
    – Tensibai
    Jun 1, 2018 at 14:00
  • @Tensibai - exit 0 will make Bamboo continue executing the following steps in the plan, since exit 0 basically means "I'm done and things went fine". I need it to stop executing.
    – Culme
    Jun 1, 2018 at 14:32
  • Misread it as stopping the script in middle vs stopping the plan. Not using bamboo so I can't tell.
    – Tensibai
    Jun 1, 2018 at 14:34
  • 1
    @kaizenCoder Thanks. But there are several task types that do not contain scripting, and in those task types - how would one introduce the conditional check?
    – Culme
    Jun 4, 2018 at 6:45
  • 1
    (On a side note: I did try to open an issue with Atlassian on this today. So I go to Bamboo forum, create feature request - system says feature requests need to be input from another system, I go to the other system, choose Bamboo as product, and the other system says I must use the Bamboo forum to submit a feature request.uuuhm. .... but.... I would love to start rambling about this, but hopefully the facts ramble by themselves.
    – Culme
    Dec 23, 2019 at 12:19

2 Answers 2

1

You can manually stop a build in progress. From Stopping an active build:

To stop an active plan build:

  1. Click Dashboard and then the All Plans tab.
  2. Click the 'Stop' icon next to the active plan you want to stop.

It also appears possible to stop the build/deploy programmatically, using the REST API, more specifically making a DELETE request to the appropriate url:

/queue/{projectKey}-{buildKey}-{buildNumber : ([0-9]+)}?stage&executeAllStages ... DELETE Stop build execution.

available response representations:

401 Returned when user does not have sufficient rights to view or execute build for specified plan

204 On success (success is also when build was already completed - so nothing to stop)

404 Returned when specified job does not exist

1

I know that is not the clean solution everybody looks for and is a nasty workaround, but what worked for me was to squash all my deployment logic into a single Script Task (shell script) and then put the necessary conditions there, such as:

if [ <put condition for terminate here> ] ; then 
   exit 0
fi 
<Continue with other execution logic>

In that way, you can exit with 0 (thus build shows as successful) , but of course that prevents you from reusing all of the out-of-the-box Bamboo Task types that are readily available and questions the benefits of using the bamboo framework as a wrapper.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.