How to extract all the trigger information for plans from Bamboo database.

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 will help provide DB queries to extract all the triggers available on Bamboo plans.

Environment

This has been tested successfully on PostgreSQL DB and will require changes for other databases. 

Solution

Below SQL can be used to extract the trigger type information.

  SELECT P.TITLE        AS PROJECT,
       B.FULL_KEY,
       B.BUILD_ID,
       B.BUILDKEY     AS BUILDKEY,
       B.DESCRIPTION  AS BUILD_DESCRIPTION,
       CAST(UNNEST(XPATH('/configuration/triggers/triggerDefinition/name/text()', XML_DEFINITION_DATA :: xml)) AS VARCHAR) AS TRIGGER_TYPE
FROM BUILD_DEFINITION BD JOIN BUILD B ON (BD.BUILD_ID = B.BUILD_ID)
JOIN PROJECT P ON (P.PROJECT_ID = B.PROJECT_ID)
ORDER BY 1, 2;


Below SQL can be used to extract the repository details for "Bitbucket server repository triggered" triggers

SELECT P.TITLE           AS PROJECT,
       B.FULL_KEY,
       B.BUILD_ID,
       B.BUILDKEY       AS BUILDKEY,
       B.DESCRIPTION    AS BUILD_DESCRIPTION,
       XPATH('//configuration/triggers/triggerDefinition/name/text()', CAST(BD.XML_DEFINITION_DATA AS XML)) AS TRIGGERING_TYPE,
       BTRIM(XPATH('//configuration/triggers/triggerDefinition/triggeringRepositories/text()',CAST(BD.XML_DEFINITION_DATA AS XML)) :: TEXT, '{},"') AS REPOSITORY_DETAILS
FROM   BUILD_DEFINITION BD,
       PROJECT P,
       BUILD B
WHERE  B.BUILD_ID = BD.BUILD_ID
       AND P.PROJECT_ID = B.PROJECT_ID
       AND BD.XML_DEFINITION_DATA LIKE '%com.atlassian.bamboo.plugins.stash.atlassian-bamboo-plugin-stash:stashTrigger%' 



Last modified on Jun 1, 2023

Was this helpful?

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