It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

6 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

6 votes
Answer accepted

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?

Like Ramesh Shetty likes this

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

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.

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.

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

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

Community showcase
Published in Jira

[Survey] Development tools and DevOps - share your thoughts!

Hey Community! I work at Atlassian in product marketing and we are conducting a survey to better understand how people feel about their development tool chain and DevOps. We would love if you could...

43 views 0 0
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you