How to understand the average / mean duration that a Bamboo build spends in queue?
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
Summary
It may be necessary to understand how long certain plans are spending waiting in the Bamboo build queue in order to allocate sufficient agent resources to ensure build throughput demands.
Solution
Bamboo UI
Bamboo includes a build-in report for build queued duration which can be run per plan (or for many plans):
- Visit Reports > Reports.
- Under Report, select Build Queued Duration.
- Choose the plans you wish to run the report for.
- Submit.
The report will produce a chart, however, if you want access to the data you can switch to the Data Table tab which will contain the average duration in milliseconds.
Use SQL
You can explore the BUILDRESULTSUMMARY table from the Bamboo Database to find similar results from the reports interface.
This is a simple query that would return the Build duration for all builds in December 2021. You can of course customise it to bring further information for you such as average times. The times in the DB are either in timestamp format or bigint (in milliseconds).
The example below works on PostgreSQL, you'll need to adapt it to other DB products.
SELECT build_date AS "Build Date",
build_key AS "Build Key",
processing_duration / 1000 :: REAL "Build duration"
FROM buildresultsummary
WHERE build_state IN ( 'Successful', 'Failed' )
AND build_type IN ( 'CHAIN', 'com.atlassian.bamboo.plan.AbstractChain',
'CHAIN_BRANCH' )
AND Extract(month FROM build_date) = 12
AND Extract(year FROM build_date) = 2021
ORDER BY build_date;
Build Date | Build Key | Build duration
-------------------------+-----------+----------------
2021-12-07 13:01:10.433 | ABC-HIJ | 2.032
2021-12-07 13:04:03.578 | ABC-HIJ | 1.038
2021-12-07 13:04:37.724 | ABC-HIJ | 0.621
2021-12-07 13:40:55.153 | ABC-HIJ | 0.823
2021-12-13 10:38:03.516 | ABC-HIJ | 2.773
2021-12-13 10:47:06.649 | ABC-HIJ | 0.454
2021-12-13 10:47:34.275 | ABC-HIJ | 0.584
2021-12-13 10:47:59.917 | ABC-HIJ | 0.749
2021-12-13 10:48:58.352 | ABC-HIJ | 0.722
2021-12-13 11:02:49.22 | ABC-HIJ | 0.672
2021-12-13 11:04:09.781 | ABC-HIJ | 0.579
2021-12-13 11:05:13.482 | ABC-HIJ | 0.692
2021-12-13 11:12:17.972 | ABC-HIJ | 0.691
2021-12-13 11:13:09.858 | ABC-HIJ | 0.465
2021-12-13 11:33:15.091 | ABC-HIJ | 0.477
2021-12-13 11:37:26.612 | ABC-HIJ | 0.51
2021-12-13 11:41:33.73 | ABC-HIJ | 0.498
2021-12-21 12:21:25.011 | MYS-BM | 3415.93
2021-12-21 17:17:17.718 | MYS-BM | 1789.263
2021-12-21 19:14:04.595 | MYS-BM | 2141.966
2021-12-21 22:40:41.398 | MYS-BM | 0.538
2021-12-21 22:41:14.928 | MYS-BM | 0.303
2021-12-21 22:53:02.502 | MYS-BM | 0.191
2021-12-21 23:43:17.676 | MYS-BM | 4.945
(...)
The BUILDRESULTSUMMARY table contains several interesting columns such as plan_name, build_number, duration, queue_time, etc that you can explore and build better reports to suit your needs.