Scott B Scott B - 10 months ago 56
reST (reStructuredText) Question

Atlassian Bamboo stop a build that is currently running/being executed

I am trying to stop bamboo builds (that are currently running) if they pass a certain use case.

I have a list of the builds that I need to stop. Now, I want to send a REST request to stop the build(s) very similar to the "Stop Build" button that is on the top right of a build (see image).
enter image description here

In the REST API documentation I have only seen this which only stops the build if it is queued.


Stop build execution, however only if build has not been started yet - so if is waiting in the build queue. If build does not exist in the queue anymore, method has no effect.

I need a way to stop RUNNING builds. Any help would be much appreciated.

Answer Source

I was able to figure out the names of the bamboo builds I needed to stop via my own automation server. Then I was able to achieve this by hitting the stopPlan button code directly. Here is the ruby method I wrote:

# Get request to stop a build located at the given url
def stop_bamboo_build_request(build_key)
  logger.debug "Build Key: #{build_key}"
  uri = URI("#{Rails.configuration.bamboo_base_url}/build/admin/stopPlan.action?planKey=#{build_key}")

  # Create client
  http =, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER

  # Create Request
  req =
  # Add Auth
  req.basic_auth(Rails.configuration.bamboo_username, Rails.configuration.bamboo_password)

  # Add headers
  req.add_field "X-Atlassian-Token", "no-check"

  # Fetch Request
  res = http.request(req)
  logger.debug "Response HTTP Status Code: #{res.code}"
  logger.debug "Response HTTP Response Body: #{res.body}"
rescue StandardError => e
  logger.debug "HTTP Request failed (#{e.message})"