SQL to show all build statuses from Bamboo

Still need help?

The Atlassian Community is here for you.

Ask the community


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

This KB demonstrates a few example SQL statements that can be used to extract build statuses reports from Bamboo

Environment

Bamboo 7.0 and later

Solution

The provided SQL instructions were tested only on PostgresSQL and MySQL. You may have to adapt the queries for other databases.

Show all past builds statuses

SELECT BRS.BUILD_KEY    AS "Build key",
       BRS.PLAN_NAME    AS "Plan",
       BRS.BUILD_NUMBER AS "Build number",
       BRS.BUILD_DATE   AS "Build date",
       BRS.BUILD_STATE  AS "Build state",
       CASE B.BUILD_TYPE
         WHEN 'CHAIN' THEN 'Plan'
         WHEN 'CHAIN_BRANCH' THEN 'Plan branch'
       END              AS "Plan type"
FROM   BUILDRESULTSUMMARY BRS
       JOIN BUILD B
         ON B.FULL_KEY = BRS.BUILD_KEY
WHERE  BRS.BUILD_TYPE = 'CHAIN'
ORDER  BY BUILD_KEY,
          BUILD_NUMBER;

Show all past builds, jobs and stages statuses

SELECT BRS.BUILD_KEY    AS "Build key",
       BRS.PLAN_NAME    AS "Plan",
       CS.NAME          AS "Stage",
       BRS.BUILD_NUMBER AS "Build number",
       BRS.BUILD_DATE   AS "Build date",
       BRS.BUILD_STATE  AS "Build state",
       CASE B.BUILD_TYPE
         WHEN 'CHAIN' THEN 'Plan'
         WHEN 'CHAIN_BRANCH' THEN 'Plan branch'
         WHEN 'JOB' THEN 'Job'
       END              AS "Plan type"
FROM   BUILDRESULTSUMMARY BRS
       JOIN BUILD B
         ON B.FULL_KEY = BRS.BUILD_KEY
       JOIN CHAIN_STAGE CS
         ON CS.BUILD_ID = B.BUILD_ID
ORDER  BY BRS.BUILD_KEY,
          BRS.BUILD_NUMBER; 




Last modified on Aug 18, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.