Trigger Bamboo Plan via REST Call?

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

5 answers

1 accepted

6 votes
Accepted answer

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

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

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

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

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.

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

"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.

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.

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

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.

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

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.

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.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in United States

Topic Tuesday: What's your favorite topic?

Good morning All, Our goal is to get you into the habit of while enjoying your favorite morning drink you are checking the NOVA "space" for topics and comments. Your input is really needed and...

57 views 4 0
View post

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