Missed Team ’24? Catch up on announcements here.

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

How to get job key of my BP using Bamboo REST API?

Valerii October 6, 2022

Hi Team,

I have {projectKey} and {buildKey}, is it possible to get {jobKey} of this BP using Bamboo REST API?

I found how to get the value as {projectKey}-{buildKey}-{jobKey} . But I need only jobKey.

1 answer

0 votes
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 6, 2022

Hello @Valerii

This jq filter will do the job:

$ curl -u admin:admin -H "Accept: application/json" -X GET \
'https://bamboo825.mydomain.net/rest/api/latest/plan/ABC-DFG?expand=stages.stage.plans.plan' \
| jq '.stages.stage | .[].plans.plan | .[].planKey | .jobKey = ( .key | split("-") | .[2])'

{
"key": "ABC-DFG-JOB1",
"jobKey": "JOB1"
}
{
"key": "ABC-DFG-FJ",
"jobKey": "FJ"
}
{
"key": "ABC-DFG-P4C",
"jobKey": "P4C"
}
{
"key": "ABC-DFG-HW",
"jobKey": "HW"
}

Best regards,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events