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

Your Points Tracker
  • 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
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?
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

Bamboo REST API: how to trigger a plan and waiting for a result

I would like to write a bash script to use the Bamboo REST API in order to trigger a plan tests and would like to wait for it to finish and get a result (failed or success).
Upon success, I would like to do something in the pipeline.

I found the following commands:
#This triggers the plan 
curl -k --user user:password -X POST -d "stage&executeAllStages"

I can parse the result of that command in order to get the build number by:
sed 's/.*buildNumber\="\([0-9]*\)".*/\1/'

I can use the extracted build number in order to query the result:
curl -k --user user:password -X GET

And then i need to parse result and do a busy wait to ask again and parse until there is an answer.
I am sure this is bad practice and would like to ask if there is one command (REST API) that do that for me. Just not returning until there is an answer.

Many thanks in advanced 


2 answers

0 votes

Hi @Ilan_Hazan

I don't see a better option to get the information you want other than using REST API and asynchronously checking if the build finished.

I have a suggestion for small improvements in your approach.

  • Try to use  jq (JSON processor) to filter the request responses. There is one example you can see jq being used: Solved: How to get deploymentResultId using REST API?
  • Try to use   <Bamboo_URL>/rest/api/latest/result/status/XXX-YYY-# (to check the build status) before calling the result itself. It should be a call with a lower cost for Bamboo and will give you the current status of the build.
  • Remember to implement a timeout in case the bamboo build has a routine that freezes it.

I guess those are pieces of advice can give you.

Like Daniel Santos likes this

I implemented the algorithm.

I improved the bash's sed regular expression and did a loop with some sleeps between the Bamboo API calls:
Bamboo REST API: how to trigger a plan and waiting for a result 

That is great @Ilan_Hazan, thank you for taking the time to share your solution here =]

Like Ilan_Hazan likes this

Suggest an answer

Log in or Sign up to answer
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 ...

251 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