Query the database for build jobs that contain a Docker Task
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
SQL query to retrieve build jobs that contain a Docker Task and information regarding that task.
Environment
Tested on Bamboo 7.2.4 with MySQL.
If your Bamboo instance is connected to a different DBMS, the query needs to be translated to the corresponding syntax.
Solution
Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
Run the following SQL query against the Bamboo database:
SELECT P.TITLE AS PROJECT_TITLE,
B2.TITLE AS PLAN_NAME,
B.TITLE AS JOB_NAME,
B.FULL_KEY AS JOB_KEY,
CONCAT('<BAMBOO-URL>/build/admin/edit/editBuildTasks.action?buildKey=',B.FULL_KEY) AS JOB_URL,
SUBSTRING_INDEX(SUBSTRING_INDEX(XML_DEFINITION_DATA, '<key>commandOption</key>
<value>',-1),
'</value>',1) as COMMAND,
SUBSTRING_INDEX(SUBSTRING_INDEX(XML_DEFINITION_DATA, '<key>repository</key>
<value>',-1),
'</value>',1) as REPOSITORY
FROM BUILD_DEFINITION
JOIN BUILD B ON
(BUILD_DEFINITION.BUILD_ID = B.BUILD_ID)
JOIN PROJECT P ON
(B.PROJECT_ID = P.PROJECT_ID)
LEFT OUTER JOIN CHAIN_STAGE CS ON (B.STAGE_ID = CS.STAGE_ID)
LEFT OUTER JOIN BUILD B2 ON (B2.BUILD_ID = CS.BUILD_ID)
WHERE XML_DEFINITION_DATA LIKE '%task.docker.cli</pluginKey>%'
Caveat
This query only retrieves the details of one Docker task in a given build job, and it's always the last one. This means that, if there are two or more Docker Tasks within the same job, only the last one will be retrieved.
Replace <BAMBOO-URL>
with your Bamboo instance URL in order to get the direct URL to the jobs in the query results.