Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How to use executeAllStages with REST API to control a build

I am using the REST API endpoint  https://mybamboo.company.com.com/rest/api/latest/queue/<ProjectKey>-<PLanKey>

According to documentation, this endpoint supports parameters stage=<nameOfStage> and executAllStage=<true/false> 

I cannot get either the stage or executeAllStages parameters to work.  Regardless of how I set them, the behavior remains the same.  The automatic stages are executed, but stop when it hits the first manual. 

Assume I have 3 stages named: Stage1, Stage2, Stage3.   Stage3 is manual

I am using the Ansible URI module, so the call looks like: 

-
uri:
  headers:
    Authorization: 'Bearer {{ bearer_token }}'
  body_format: raw
  body:   stage=Stage3&executeAllStages=true
  method: POST
  url: https://mybamboo.company.com/rest/api/latest/queue/TAU-ETX/
  

The equivalent curl would be:

curl --fail 

  -H "Authorization: Bearer <XXX>"

  -X POST

  -d "stage=Stage3&executeAllStages=true"

  --location https://mybamboo.company.com.com/rest/api/latest/queue/TAU-ETX

In both formats, the call runs without errors, but no matter how I set the values for stage and executeAllStages, Stage1 and Stage2 are run, Stage3 is not.

There are a lot of questions about this and closely related issues, the best answer I have found being https://community.atlassian.com/t5/Bamboo-questions/Rest-Api-to-start-a-stage-for-build/qaq-p/786887 but I have not been able to get by this.

Can someone help me find my error or confirm there is a bug?

 

2 answers

1 accepted

1 vote
Answer accepted
Cristiano Mariano
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.
Dec 06, 2021

Hi @james_mckean ! How are you doing?

Did you try to add the stage and/or executeAllStages parameter to the end of the URL instead of passing it as a body?

Hope this helps!

Sorry for the long wait. 

I am used to using Ansible, so my curl formatting is rusty.   If you mean something like 

curl --fail -H "Authorization: bearer XXX" -X POST https://bamboo.mybamboo.com/rest/api/latest/queue/TAU-ETX?stage=3&executeAllStages=true

then I get an error like

no matches found: https://bamboo.dev.mybamboo.com/rest/api/latest/queue/TAU-ETX?stage=3&executeAllStages=true
Like Cristiano Mariano likes this

Oh, wait. I am in a zsh shell so apparently the ? needs to be escaped with double quotes.  

Like Cristiano Mariano likes this

OK, further experimenting.  I cannot get the bearer token to work, but basic authentication does.  Final working format is:

curl --fail -k --user <user>:<password>   -X POST https://bamboo.mybamboo.com/rest/api/latest/queue/TAU-ETX"?stage=3&executeAllStages=true"

This builds all stages including the manual one.  Now I just have to figure out how to accomplish the same in Ansible.  

Thanks for the hint.

Like # people like this
Cristiano Mariano
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.
Dec 14, 2021

Hi @james_mckean !

I am very glad to hear that it worked.

And thanks for give back the Ansible example to the community!

For anyone else trying to make this work in Ansible, the correct format is

name: 'execute all stages test'
hosts: localhost
tasks:
-
uri:
headers:
Authorization: 'Bearer {{ bearer_token }}'
method: POST
url: "https://bamboo.myBamboo.com/rest/api/latest/queue/TAU-ETX/?stage=Stage3&executeAllStages=true"
validate_certs: false 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events