How to filter Bamboo plans using a particular task type or having a particular text via DB queries

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問


プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

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.

*Fisheye および Crucible は除く

要約

The purpose of this page is to provide a DB query that will help pull out the details of the plans using below task types in Bamboo.

  1. Maven and it's version
  2. Node JS and it's version
  3. Ant and it's version

This page also contains a SQL query using which you can use to filter a plan for a particular text. 

The content on this page relates to platforms which are supported; however, the content is out of scope of our Atlassian Support Offerings. Consequently, Atlassian cannot guarantee support. Please be aware that this material is provided for your information only and you may use it at your own risk.

環境

Queries have been tested on Bamboo 8.1.3 on PostgreSQL and Oracle DB

ソリューション

PostgreSQL DB query for tasks using Maven 3
SELECT B.FULL_KEY AS JOB_KEY,B.TITLE AS JOB_NAME, B1.FULL_KEY AS PLAN_KEY, B1.TITLE AS PLAN_NAME , XPATH('//configuration/buildTasks/taskDefinition[pluginKey/text()="com.atlassian.bamboo.plugins.maven:task.builder.mvn3"]/config/item[key/text()="label"]/value/text()', cast(BD.xml_definition_data as xml)) AS VERSION
FROM BUILD B, BUILD_DEFINITION BD , CHAIN_STAGE CS , BUILD B1

WHERE B.BUILD_ID=BD.BUILD_ID
AND B.STAGE_ID=CS.STAGE_ID
AND B1.BUILD_ID=CS.BUILD_ID 
AND BD.XML_DEFINITION_DATA LIKE '%com.atlassian.bamboo.plugins.maven:task.builder.mvn3%'

ORDER BY PLAN_KEY

The above query will give results for all the Jobs which are configured with Maven 3 if you want to get results for Maven 2 and Maven 1, you will need to replace com.atlassian.bamboo.plugins.maven:task.builder.mvn3 in the above query at 2 places with the below values

  1. For Maven 2 : com.atlassian.bamboo.plugins.maven:task.builder.mvn2
  2. For Maven 1 : com.atlassian.bamboo.plugins.maven:task.builder.maven
PostgreSQL DB query for tasks using Ant
SELECT B.FULL_KEY AS JOB_KEY,B.TITLE AS JOB_NAME, B1.FULL_KEY AS PLAN_KEY, B1.TITLE AS PLAN_NAME , XPATH('//configuration/buildTasks/taskDefinition[pluginKey/text()="com.atlassian.bamboo.plugins.ant:task.builder.ant"]/config/item[key/text()="label"]/value/text()', cast(BD.xml_definition_data as xml)) AS VERSION
FROM BUILD B, BUILD_DEFINITION BD , CHAIN_STAGE CS , BUILD B1

WHERE B.BUILD_ID=BD.BUILD_ID
AND B.STAGE_ID=CS.STAGE_ID
AND B1.BUILD_ID=CS.BUILD_ID 
AND BD.XML_DEFINITION_DATA LIKE '%com.atlassian.bamboo.plugins.ant:task.builder.ant%'

ORDER BY PLAN_KEY
PostgreSQL DB query for tasks using Node JS
SELECT B.FULL_KEY AS JOB_KEY,B.TITLE AS JOB_NAME, B1.FULL_KEY AS PLAN_KEY, B1.TITLE AS PLAN_NAME , XPATH('//configuration/buildTasks/taskDefinition[pluginKey/text()="com.atlassian.bamboo.plugins.bamboo-nodejs-plugin:task.builder.node"]/config/item[key/text()="runtime"]/value/text()', cast(BD.xml_definition_data as xml)) AS VERSION
FROM BUILD B, BUILD_DEFINITION BD , CHAIN_STAGE CS , BUILD B1

WHERE B.BUILD_ID=BD.BUILD_ID
AND B.STAGE_ID=CS.STAGE_ID
AND B1.BUILD_ID=CS.BUILD_ID 
AND BD.XML_DEFINITION_DATA LIKE '%com.atlassian.bamboo.plugins.bamboo-nodejs-plugin:task.builder.node%'
SQL query to filter a plan for a particular text
SELECT B.FULL_KEY AS JOB_KEY,B.TITLE AS JOB_NAME, B1.FULL_KEY AS PLAN_KEY, B1.TITLE AS PLAN_NAME
FROM BUILD B, BUILD_DEFINITION BD , CHAIN_STAGE CS , BUILD B1

WHERE B.BUILD_ID=BD.BUILD_ID
AND B.STAGE_ID=CS.STAGE_ID
AND B1.BUILD_ID=CS.BUILD_ID 
AND BD.XML_DEFINITION_DATA LIKE '%sample_text%'

ORDER BY PLAN_KEY

(info) Please replace sample_text with the text which you are looking to filter


How to convert above PostgreSQL queries to Oracle

There will be change to only one function which is being used to query XML_DEFINITION_DATA column from BUILD_DEFINTION table, below are the change in functions.


PostgreSQL
XPATH('//configuration/buildTasks/taskDefinition[pluginKey/text()="com.atlassian.bamboo.plugins.ant:task.builder.ant"]/config/item[key/text()="label"]/value/text()', cast(BD.xml_definition_data as xml)) AS VERSION
Oracle
XMLTYPE(BD.XML_DEFINITION_DATA).EXTRACT('//configuration/buildTasks/taskDefinition[pluginKey/text()="com.atlassian.bamboo.plugins.ant:task.builder.ant"]/config/item[key/text()="label"]/value/text()').getStringVal() VERSION
Oracle DB query for Ant task
SELECT B.FULL_KEY AS JOB_KEY,B.TITLE AS JOB_NAME, B1.FULL_KEY AS PLAN_KEY, B1.TITLE AS PLAN_NAME , 
XMLTYPE(BD.XML_DEFINITION_DATA).EXTRACT('//configuration/buildTasks/taskDefinition[pluginKey/text()="com.atlassian.bamboo.plugins.ant:task.builder.ant"]/config/item[key/text()="label"]/value/text()').getStringVal() VERSION
FROM BUILD B, BUILD_DEFINITION BD , CHAIN_STAGE CS , BUILD B1

WHERE B.BUILD_ID=BD.BUILD_ID
AND B.STAGE_ID=CS.STAGE_ID
AND B1.BUILD_ID=CS.BUILD_ID 
AND BD.XML_DEFINITION_DATA LIKE '%com.atlassian.bamboo.plugins.ant:task.builder.ant%'

ORDER BY PLAN_KEY

最終更新日 2024 年 4 月 18 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.