Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Rest Api to start a stage for build

According to the Bamboo REST api I can trigger a build by using

curl -u {user:pwd} -X POST https://{server}/rest/api/latest/queue/{build-plan}?stage&executeAllStages

I have a build plan with two stages (CI Build, IntegrationTest) and want to trigger the second stage. The IntegrationTest stage is a manual stage. 

So I tried   
    curl -u {user:pwd} -X POST https://{server}/rest/api/latest/queue/{build-plan}?stage=IntegrationTest&executeAllStages=false

As a result, the plan executes the CI Build stage, and after the completion also the IntegrationTest stage. I assumed that the CI build phase would be skipped by the executeAllStages=false parameter. Is that not the supposed behavior?

1 answer

The Bamboo REST API and esp. its documentation leaves a lot to be desired unfortunately. Regardless, based on the docs for /queue/{projectKey}-{buildKey}-{buildNumber : ([0-9]+)}?stage&executeAllStages, I've been able to trigger a build with one automatic and two manual stages in various ways as follows:

  • https://{{host}}/bamboo/rest/api/latest/queue/TST-NMS => runs first automatic stage only
  • https://{{host}}/bamboo/rest/api/latest/queue/TST-NMS?stage=Second => runs up to and including the second manual stage, but excludes the subsequent third stage
  • https://{{host}}/bamboo/rest/api/latest/queue/TST-NMS?stage=Third => runs up to and including the third manual stage and thus yields a complete plan build

This matches the documented behavior for parameter 'stage':

name of the stage that should be executed even if manual stage. Execution will follow to the next manual stage after this or end of plan if no subsequent manual stage

So you can achieve your goal as long as you know the name of the last stage in the plan. This is the one limitation that 'executeAllStages' is supposed to address it seems. And in fact this seems to work just fine if used standalone as follows:

  • https://{{host}}/bamboo/rest/api/latest/queue/TST-NMS?executeAllStages=true => runs up to and including the third manual stage and thus yields a complete plan build
  • https://{{host}}/bamboo/rest/api/latest/queue/TST-NMS?executeAllStages=false => runs automatic stages only
  • https://{{host}}/bamboo/rest/api/latest/queue/TST-NMS?executeAllStages => also runs automatic stages only, i.e. defaults to false then

This also matches the documented behavior for parameter 'executeAllStages':

enforce executing all stages in a plan, even if defined as manual stages. Execution will follow and include latest stage, unless some stage will fail.

Finally, your scenario using both parameters also seems to work correctly, albeit with a subtle twist:

  • https://{{host}}/bamboo/rest/api/latest/queue/TST-NMS?stage=Second&executeAllStages=false => runs up to and including the second manual stage, but excludes the subsequent third stage
  • https://{{host}}/bamboo/rest/api/latest/queue/TST-NMS?stage=Second&executeAllStages=true=> runs up to and including the third manual stage and thus yields a complete plan build

So it seems that an explicitly specified stage is evaluated and obeyed first, yet 'executeAllStages' still applies thereafter, which seems to make sense once there is more than one subsequent manual stage involved.

Hi ,

This is really useful.  I noticed the following though:

If stage=Second was already executed before and I do this:

https://{{host}}/bamboo/rest/api/latest/queue/TST-NMS?stage=Second&executeAllStages=false

 

Stage 3 will be executed though the expectation is nothing will happen since stage 2 has completed and executeAllStages is set to false

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bamboo

Bamboo 101 Video

G’day Community! As we gear up to introduce Bamboo Data Center to the world, we wanted to make sure that we shared a bit more about Bamboo, the product. Our team has put together an overview video ...

219 views 4 6
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