How to fetch Bamboo agent build success percentage via DB query
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
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!
Summary
The purpose of this page is to fetch the success rate of all the agents in Bamboo via DB query. Currently this can be seen on the GUI under agent summary page for individual agents as below
Environment
All supported version of Bamboo
Solution
Below query has been written which queries the below 2 tables to extract the results
1) BUILDRESULTSUMMARY - This table contains the details related to the build results
2) QUEUE - This table contains the details related to the agent
SELECT Q.TITLE AS Agent_Name,
COUNT(DISTINCT BRS1.BUILDRESULTSUMMARY_ID) AS Total_Builds,
COUNT(DISTINCT BRS.BUILDRESULTSUMMARY_ID) AS Total_Successful_Builds,
COUNT(DISTINCT BRS.BUILDRESULTSUMMARY_ID) * 100 /
COUNT(DISTINCT BRS1.BUILDRESULTSUMMARY_ID) AS Agent_Successful_Percentage
FROM BUILDRESULTSUMMARY BRS,
BUILDRESULTSUMMARY BRS1,
QUEUE Q,
QUEUE Q1
WHERE BRS.BUILD_AGENT_ID = Q.QUEUE_ID
AND BRS.BUILD_AGENT_ID = Q1.QUEUE_ID
AND BRS.BUILD_STATE = 'Successful'
AND BRS1.BUILD_AGENT_ID = Q.QUEUE_ID
AND BRS1.BUILD_AGENT_ID = Q1.QUEUE_ID
GROUP BY Q.TITLE
Please note the above query has been test successfully in PostgreSQL DB and might need modifications for other DB types