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

Using the Python API, how do I get the build statuses of different branches?

Jonathan Herron
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 14, 2023

I have a build status bot that monitors the statuses of various plans. I also want it to monitor the statuses of all the branches of all the plans. Once I had the plan_key and branch_name, I used to be able to do this with:

branch_info = bamboo.get_branch_info(plan_key=plan_key, branch_name=branch_name)

branch_number = branch_info['latestResult']['number']

But it's breaking on the second line now. Looks like branch_info doesn't hold the latestResult anymore? 

Also, I tried using bamboo.build_latest_result(plan_key=branch_key) and that also doesn't work. I might be missing something silly.

1 answer

1 vote
Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 15, 2023

Hello Jonathan,

I am not an expert in Python, but you can get these info by Bamboo REST API's

1) Use the below REST API to filter all the branches for a plan

    /rest/api/latest/plan/plan-key/branch , refer https://docs.atlassian.com/atlassian-bamboo/REST/8.2.5/#d2e2400

2) Using the below API you can get the branch status

   /rest/api/latest/result/<branch-key>, refer https://docs.atlassian.com/atlassian-bamboo/REST/8.2.5/#d2e3305

You can refer the below community article for details > https://community.atlassian.com/t5/Bamboo-articles/How-to-list-plan-build-status-using-REST-API/ba-p/1142159

Jonathan Herron
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 16, 2023

Thanks for your reply! I think it's specific to the Python API then because I was able to get the latest result through rest using /rest/api/latest/result/<branch-key>

But in Python, bamboo.latest_result(plan_key) doesn't work if I use the branch_key for the play_key argument. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events