How to retrieve all plans and deployments that reference a keyword in their tasks
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 provides SQL queries to retrieve plans and deployments that reference a specific keyword in their tasks.
Environment
Tested on Bamboo 8.1.8 with Oracle.
Solution
The following queries were tested on an Oracle database. For other DBMSs, the queries might need adjustments in order to work.
Please replace KEYWORD in the WHERE clause with the keyword you're looking for.
You can uncomment the following line in the queries to also filter for builds and deployments that were used recently.
--AND BRS.BUILD_DATE >= '31-10-2022 00.00.00'
--AND DR.FINISHED_DATE >= '31-10-2022 00.00.00'
Please make sure to adjust the date (31-10-2022 00.00.00) in the WHERE clause according to your needs. This will list deployments and builds that were executed on that date or more recently.
Plans that reference a keyword in their tasks
SELECT PROJECT,
PLAN_KEY,
BUILD_TYPE,
MAX(BUILD_DATE) AS LATEST_BUILD
FROM
(SELECT P.TITLE AS PROJECT,
B.FULL_KEY AS PLAN_KEY,
B.BUILD_TYPE AS BUILD_TYPE,
BRS.BUILD_DATE AS BUILD_DATE
FROM BUILD B
JOIN BUILD_DEFINITION BD ON B.BUILD_ID = BD.BUILD_ID
JOIN PROJECT P ON B.PROJECT_ID = P.PROJECT_ID
JOIN BUILDRESULTSUMMARY BRS ON BRS.BUILD_KEY = B.FULL_KEY
WHERE BD.XML_DEFINITION_DATA LIKE ('%<buildTasks>%KEYWORD%')
--AND BRS.BUILD_DATE >= '31-10-2022 00.00.00'
ORDER BY PROJECT,
PLAN_KEY)
GROUP BY (PLAN_KEY,
BUILD_TYPE,
PROJECT)
Deployments that reference a keyword in their tasks
SELECT DEPLOYMENT,
PLAN_KEY,
ENVIRONMENT,
MAX(LAST_FINISHED_DATE)
FROM
(SELECT DP.NAME AS "DEPLOYMENT",
DP.PLAN_KEY AS "PLAN_KEY",
DE.NAME AS "ENVIRONMENT",
DR.FINISHED_DATE AS "LAST_FINISHED_DATE"
FROM DEPLOYMENT_PROJECT DP
JOIN DEPLOYMENT_ENVIRONMENT DE ON DP.DEPLOYMENT_PROJECT_ID = DE.PACKAGE_DEFINITION_ID
JOIN DEPLOYMENT_RESULT DR ON DE.ENVIRONMENT_ID = DR.ENVIRONMENT_ID
WHERE DE.XML_DEFINITION_DATA like '%KEYWORD%'
--AND DR.FINISHED_DATE >= '31-10-2022 00.00.00'
ORDER BY 1,
2,
3)
GROUP BY (PLAN_KEY,
DEPLOYMENT,
ENVIRONMENT)