How to find currently running jobs
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Purpose
This article demonstrates how to find which Build jobs are currently running on Bamboo.
Solution
REST API
The Bamboo REST endpoints listed in this article impose a reduced amount of results by default. If you would like to have more results, we advise you to add the max-results=<number> parameter on the requests below. Please adjust that as required.
For example, to retrieve 1000 results, use: <bamboo-url>/rest/api/latest/result?includeAllStates=true&lifeCycleState=InProgress&max-results=1000
You can find running jobs through the API with the following call. Then filter it using jq
:
$ curl -s -H "Accept: application/json" -u<bamboo-user>:<bamboo-pass> \
"<bamboo-url>/rest/api/latest/result?includeAllStates=true&lifeCycleState=InProgress" \
| jq '.results.result[]'
If you are also looking to include statuses from Plan branches, you will need to expand the request as the main /result
REST endpoint will only return information from the top-level plans. We have an open feature request that asks for an enhancement of the generic implementation of the /result endpoint
BAM-21991
-
Getting issue details...
STATUS
# Extract the plan list and add to variable
$ PLANS=`curl -s -H "Accept: application/json" -u<bamboo-user>:<bamboo-pass> "https://<bamboo-url>/rest/api/latest/plan" | jq -r '.plans.plan[].key'`
# Extract the plan branches list and add to variable
$ PLAN_BRANCHES=`for p in ${PLANS} ; do curl -s -H "Accept: application/json" -u<bamboo-user>:<bamboo-pass> "https://<bamboo-url>/rest/api/latest/plan/${p}/branch" | jq --arg PLAN "${p}/" -r '$PLAN + .branches.branch[].shortName' ; done`
# Get the results for all plan branches
$ for PB in ${PLAN_BRANCHES} ; do curl -s -H "Accept: application/json" -u<bamboo-user>:<bamboo-pass> "https://<bamboo-url>/rest/api/latest/result/${PB%/*}/branch/${PB#*/}?includeAllStates=true&lifeCycleState=InProgress" | jq 'select(.results.size > 0) | .results.result[]'; done
For more information and additional options, check the REST API calls documentation below:
- https://developer.atlassian.com/server/bamboo/rest/api-group-api/#api-api-latest-result-get
- https://developer.atlassian.com/server/bamboo/rest/api-group-api/#api-api-latest-plan-projectkey-buildkey-get
- https://developer.atlassian.com/server/bamboo/rest/api-group-api/#api-api-latest-result-projectkey-buildkey-branch-branchname-get
Database
Alternatively, you can run the following database query.
SELECT *
FROM buildresultsummary
WHERE life_cycle_state = 'InProgress'
AND build_type = 'BUILD';