Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Trigger Bamboo Plan via REST Call?

Jeffrey Doto June 27, 2012

Hello,

Is it possible to trigger a bamboo plan remotely through the REST API? I want to create a script to run serially run all of our builds. If there is no REST API call, can you create a plan of existing plans?

We're running Bamboo 4.0.1 build 2907.

Thanks


Jeff

6 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

7 votes
Answer accepted
Thomas Boyles October 3, 2012

A cURL example

export BAMBOO_USER=foo
export BAMBOO_PASS=bar
export PROJECT_NAME=TST
export PLAN_NAME=DMY
export STAGE_NAME=JOB1

curl --user $BAMBOO_USER:$BAMBOO_PASS -X POST -d "$STAGE_NAME&ExecuteAllStages" http://mybamboohost:8085/rest/api/latest/queue/$PROJECT_NAME-$PLAN_NAME

Peter Kahn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 27, 2014

Did you run into 401 auth errors? I keep on hitting them and I'm not sure how to work around them

Peter Kahn
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 27, 2014

Ah, my new plan didn't allow the user in question rights to build. So, 401 was expected. Silly me.

Haani_Niyaz August 26, 2014

Hi Thomas, Would you know if its possible to execute a single stage within a plan?

Joe Levis April 7, 2015

I was wondering the same thing Haani. You would think if you have to specify "Stage&ExecuteAllStages", you would be able to specify just "Stage". I've tested this on Bamboo 5.7.1 with no success. All in all, I guess it makes sense that you can't run a single Stage, since Stages are meant to me sequential and executed only after the previous Stage is successful. In which case, the only option for isolating a specific Stage would be to create a separate build plan. Not ideal, but that's where I've landed.

Ankit Pandy September 7, 2015

"HTTP Status 405 - The specified HTTP method is not allowed for the requested resource." .. I am getting this error ..please help me out

Claudio Omar Melendrez Baeza February 16, 2016

"my new plan didn't allow the user in question rights to build. So, 401 was expected." Actually, a 403 would be more adequate I think.

4 votes
Adam Myatt
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2012

Jeff,

I think you want the API call :

/queue/{projectKey}-{buildKey}?stage&executeAllStages

defined on this page : http://docs.atlassian.com/bamboo/REST/4.0/

which states :

Fire build execution for specified plan. Effectively, this method adds build to the build queue, so is not guarantied that build would be executed immediately. Depending on currently executed builds and length of build queue, build may be executed when queue would be drained. Additional variables could be passed to this method either as form encoded POST payload or query parameters. PLEASE note: Query parameters are more important - override those stored in form payload. Variables defined in Bamboo as global variables or plan variables MUST be prefixed with bamboo.variable ie. bamboo.variable.myVariable=valueForMyVariable. When global or plan variables would be passed to this method, will override default values for variables.

Pooja Rajiv Ranjan October 22, 2015

Can anyone give the syntax of this REST call in Python?

Like Ramesh Shetty likes this
Mahesh Pawar September 23, 2018

url=http://mybamboohost:8085/rest/api/latest/queue/$PROJECT_NAME-$PLAN_NAME

headers={'Authorization':'Basic %s'% userpass}
response = requests.get(url,headers=headers)

you can get result  via response.content.

response.content will give a html page if any error or nothing when suceess.

Like Ramesh Shetty likes this
Ramesh Shetty July 18, 2019

Hi,

 

Thank you for the post.

Can anyone please help us to understand how we can call PUT request by passing variable values in Python.

This is required to Build Plan (Customised) with parameter from our application server.

 

Thanks a lot.

2 votes
Mark de Bont
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 30, 2016

Using wget:

 

wget --save-cookies cookies.txt --post-data "os_username=XXX&os_password=XXX&os_cookie=true" "http://URL/bamboo/userlogin/!default.action"
wget --load-cookies cookies.txt --header="Content-Type: application/xml" --header="X-Atlassian-Token: no-check" --post-data="PLAN&ExecuteAllStages" http://URL/rest/api/latest/queue/PLAN1
0 votes
VikasB February 21, 2019

There is Bamboo plugin to enable you to do it as a part of any plan. It adds tasks to run plan, create deployment/rollback etc.

https://marketplace.atlassian.com/apps/1215720/plan-runners-for-bamboo

0 votes
Kothandaraman October 13, 2016

Hi All

I am facing an issue while trigger the bamboo5 build using REST API java client. I am getting the 405 error

 

Let say PROJECT KEY = ABC

PLAN_KEY=XYZ

 

Can anyone send me the piece of java code to trigger the bamboo build using java client

 

Note: I have written the java code to access JIRA updating status etc using REST API from java client i tried similar code to access but it's not going through. Also i haven't see any clear documentation how to trigger bamboo5 using java calling rest api

 

Please provide me some kind of example. It will help

 

Thanks in advance.

0 votes
Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 27, 2012

Another option is to use queueBuild from the Bamboo Command Line Interface . It has an option to wait for the build to complete so that you can serialize actions.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events