How to find the number of jobs in the Bamboo Data Center queue from the database
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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
Summary
The steps outlined on this article are provided AS-IS. This means we've had reports of them working for some customers — under certain circumstances — yet are not officially supported, nor can we guarantee they'll work for your specific scenario.
You may follow through and validate them on your own non-prod environments prior to production or fall back to supported alternatives if they don't work out.
We also invite you to reach out to our Community for matters that fall beyond Atlassian's scope of support!
If you would like to know how many builds and deployment jobs that has been queued in Bamboo you can check the Build Activity page.
Alternatively if you would like to query Bamboo database you can use the below SQL.
Environment
Bamboo Data Center 9+
Tested on Postgres Database.
Solution
The query combines the build jobs and deployment jobs in the queue.
1
2
3
4
5
6
7
8
9
10
11
12
13
SELECT LIFE_CYCLE_STATE,
SUM(TOTAL_COUNT) AS TOTAL_COUNT
FROM (SELECT LIFE_CYCLE_STATE,
COUNT(*) AS TOTAL_COUNT
FROM BUILDRESULTSUMMARY B
WHERE BUILD_TYPE = 'BUILD'
GROUP BY LIFE_CYCLE_STATE
UNION ALL
SELECT LIFE_CYCLE_STATE,
COUNT(*) AS TOTAL_COUNT
FROM DEPLOYMENT_RESULT DR
GROUP BY LIFE_CYCLE_STATE) AS COMBINED_RESULTS
GROUP BY LIFE_CYCLE_STATE;
Below are the sample values that life_cycle_state
column can contain.
Pending: The build pending status - as long as the build is not queued
Queued: The build is queued, as long as agent hasn't started the build process
InProgress: The build is really building, so once checkout started on agent
Finished: The Build finished
NotBuilt: The Build was not built
Sample outcome of the above query shows as below.

Was this helpful?