Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Using REST Api to query plan, stage, job and task detail

Ron Turner
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!
April 30, 2024

I have created a Bamboo project ( version 9.2.11) with a plan that includes stages jobs and tasks. I have not yet built the project only configured the plan stages jobs and tasks.

I am able to use the REST API to query project and plan information with no problem.

For example, "https://bamboo....../bamboo/rest/api/latest/project/<PROJECT-KEY>" returns my project name.

For example, "https://bamboo....../bamboo/rest/api/latest/project/<PROJECT-KEY>?expand=plans" returns a list of my plans

For example, "https://bamboo....../bamboo/rest/api/latest/plan/<PLAN-KEY>?expand=stages"  returns stages for a given plan.

These all work fine. The issue comes in when I attempt  to query deeper into a stage to get job and task information. What would the syntax be list out all the jobs in a stage? What about all the tasks in a job? What about the config information for a task?

Thanks

 

1 answer

1 accepted

1 vote
Answer accepted
Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 30, 2024

Hello Ron,

Welcome to Atlassian Community.

For Jobs you can use the below REST API, details are available here 

 curl --request GET \
--user user_id:password \
--url 'http://bamboo921:8085/rest/api/latest/search/jobs/PLAN-KEY' \
--header 'Accept: application/json'

 For Tasks currently there is no REST API, however there is a feature request created you can refer for more details BAM-20540 API to produce a list of build plans and their corresponding tasks 

There are couple of workarounds you can follow for example

1. Export the plan as specs via REST API to view all the plans, Jobs and the Tasks

2. Run a DB query to extract the result from the Database.

Do let me know if anyone of the workarounds interests you, I'll try to help you with that.

Regards,

Shashank Kumar

**please don't forget to Accept the answer if your query was answered**

Dustin Cheng
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!
July 22, 2025

Hi Shashank!

I have a similar requirement and I'm interested to see what workarounds you are referring to.

Can you you provide some examples for these?


There are couple of workarounds you can follow for example

1. Export the plan as specs via REST API to view all the plans, Jobs and the Tasks

2. Run a DB query to extract the result from the Database.


In particular I'm interested in extracting all the script definitions (I assume via some XML payload).

I've seen something similar from the deployment_environment table but it's not really what's in the plan > stages > jobs > tasks > script which is what I need.

Thanks!

Dustin

Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 22, 2025

Hello Dustin,

Welcome to Atlassian community.

1. Export the plan as specs via REST API to view all the plans, Jobs and the Tasks

You can use the below script

#!/bin/bash
set -euo pipefail

PLAN=$1
curl --location --request GET "https://<your-bamboo-server>/rest/api/latest/plan/${PLAN}/specs" \
--header 'Accept: application/json' \
--header "Authorization: Bearer ${BAMBOO_API_TOKEN}" | \
jq -r '.spec.code' | tr '\n' '\0' | xargs -0 printf '%b\n' > "${PLAN}".yaml

This script takes the plan key as an argument, downloads the plan configuration, and saves it as a YAML file

2. Run a DB query to extract the result from the Database.

https://support.atlassian.com/bamboo/kb/how-to-extract-list-of-jobs-in-bamboo-that-have-an-specific-task-by-using-an-sql-query/ - You can refer this and see if it helps

Regards,

Shashank Kumar

**please don't forget to Accept the answer if your query was answered**

Dustin Cheng
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!
July 23, 2025

Hey SHashank!

 

The spec endpoint you shared looks very promising and has the data I'm looking for! Thanks for this!

Just confirming, in your 2nd point, did you mean to say that the same data should be available in the database as well? I've been looking high and low and I can't seem to find the same data. (e.g. bash scripts).

 

Cheers!

 

Dustin

Shashank Kumar
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 23, 2025

Hey Dustin,

The DB results what you are looking for would be under BUILD_DEFINITION table column XML_DEFINITION_DATA in a XML format which you'll need to parse

Regards,

Shashank Kumar

Dustin Cheng
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!
July 23, 2025

Gotcha! You are 100% correct. I just needed to filter the row on the "JOB" build_type and it is exactly what I needed.

Thank you!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events