How to query Plan Branch Details from the Bamboo Database
関連コンテンツ
- 関連コンテンツがありません
プラットフォームについて: 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 は除く
目的
You may want to use details about your Plan Branches that are not available from the Bamboo UI, including for example, which Plan and Project the branch belongs to.
ソリューション
Please run the following queries in your Bamboo database, depending on the database engine that you use.
MySQL
Click here for query...
SELECT COALESCE(VL.NAME, VLX.NAME, PARENT.NAME) AS REPO_NAME,
COALESCE(B.FULL_KEY, VLX.PLAN_KEY, PARENT.PLAN_KEY) AS PLAN_KEY,
COALESCE(B.BUILD_TYPE, VLX.BUILD_TYPE, PARENT.BUILD_TYPE) BUILD_TYPE,
COALESCE(B.TITLE, VLX.PLAN_TITLE, PARENT.PLAN_TITLE) TITLE,
COALESCE(VLX.REPOSITORY_TYPE, PARENT.REPOSITORY_TYPE) AS REPO_TYPE,
COALESCE(VLX.XML, PARENT.XML) AS BRANCH
FROM VCS_LOCATION AS VL
LEFT JOIN PLAN_VCS_LOCATION AS PVL ON PVL.VCS_LOCATION_ID = VL.VCS_LOCATION_ID
LEFT JOIN BUILD AS B ON PVL.PLAN_ID = B.BUILD_ID
LEFT JOIN
(SELECT VL.PARENT_ID,
B.FULL_KEY AS PLAN_KEY,
BUILD_TYPE,
B.TITLE AS PLAN_TITLE,
VL.PLUGIN_KEY AS REPOSITORY_TYPE,
VL.VCS_LOCATION_ID,
ExtractValue(VL.XML_DEFINITION_DATA, '//repository/vcsBranch/name') AS XML
FROM VCS_LOCATION as VL
LEFT JOIN PLAN_VCS_LOCATION AS PVL ON PVL.VCS_LOCATION_ID = VL.VCS_LOCATION_ID
LEFT JOIN BUILD AS B ON PVL.PLAN_ID = B.BUILD_ID
LEFT JOIN BUILD_DEFINITION AS BD ON B.BUILD_ID = BD.BUILD_ID) VLX
ON (VLX.VCS_LOCATION_ID = VL.VCS_LOCATION_ID)
LEFT JOIN
(SELECT B.FULL_KEY AS PLAN_KEY,
BUILD_TYPE,
B.TITLE AS PLAN_TITLE,
VL.PLUGIN_KEY AS REPOSITORY_TYPE,
VL.VCS_LOCATION_ID,
ExtractValue(VL.XML_DEFINITION_DATA, '//repository/vcsBranch/name') AS XML
FROM VCS_LOCATION as VL
LEFT JOIN PLAN_VCS_LOCATION AS PVL ON PVL.VCS_LOCATION_ID = VL.VCS_LOCATION_ID
LEFT JOIN BUILD AS B ON PVL.PLAN_ID = B.BUILD_ID) AS PARENT ON (VL.PARENT_ID = PARENT.VCS_LOCATION_ID)
WHERE COALESCE(B.FULL_KEY, VLX.PLAN_KEY, PARENT.PLAN_KEY) is not NULL ;
PostgreSQL
Click here for query...
SELECT COALESCE(VL.NAME, VLX.NAME, PARENT.NAME) AS REPO_NAME,
COALESCE(B.FULL_KEY, VLX.PLAN_KEY, PARENT.PLAN_KEY) AS PLAN_KEY,
COALESCE(B.BUILD_TYPE, VLX.BUILD_TYPE, PARENT.BUILD_TYPE) BUILD_TYPE,
COALESCE(B.TITLE, VLX.PLAN_TITLE, PARENT.PLAN_TITLE) TITLE,
TRIM(LEADING ':' FROM SUBSTRING(COALESCE(VL.PLUGIN_KEY, VLX.REPOSITORY_TYPE, PARENT.REPOSITORY_TYPE) from ':.*$')) REPOSITORY_TYPE,
COALESCE(VLX.XML, PARENT.XML) AS BRANCH
FROM VCS_LOCATION AS VL
LEFT JOIN PLAN_VCS_LOCATION AS PVL ON PVL.VCS_LOCATION_ID = VL.VCS_LOCATION_ID
LEFT JOIN BUILD AS B ON PVL.PLAN_ID = B.BUILD_ID
LEFT JOIN
(SELECT B.FULL_KEY AS PLAN_KEY,
BUILD_TYPE,
B.TITLE AS PLAN_TITLE,
VL.PLUGIN_KEY AS REPOSITORY_TYPE,
VL.VCS_LOCATION_ID,
unnest(xpath('//vcsBranch[@class="com.atlassian.bamboo.plan.branch.VcsBranchImpl"]/name/text()',CAST(VL.XML_DEFINITION_DATA as XML)))::text AS XML, VL.NAME
FROM VCS_LOCATION VL
LEFT JOIN PLAN_VCS_LOCATION AS PVL ON PVL.VCS_LOCATION_ID = VL.VCS_LOCATION_ID
LEFT JOIN BUILD AS B ON PVL.PLAN_ID = B.BUILD_ID) VLX
ON (VLX.VCS_LOCATION_ID = VL.VCS_LOCATION_ID)
LEFT JOIN
(SELECT B.FULL_KEY AS PLAN_KEY,
BUILD_TYPE,
B.TITLE AS PLAN_TITLE,
VL.PLUGIN_KEY AS REPOSITORY_TYPE,
VL.VCS_LOCATION_ID,
unnest(xpath('//vcsBranch[@class="com.atlassian.bamboo.plan.branch.VcsBranchImpl"]/name/text()',CAST(VL.XML_DEFINITION_DATA as XML)))::text AS XML, VL.NAME
FROM VCS_LOCATION VL
LEFT JOIN PLAN_VCS_LOCATION AS PVL ON PVL.VCS_LOCATION_ID = VL.VCS_LOCATION_ID
LEFT JOIN BUILD AS B ON PVL.PLAN_ID = B.BUILD_ID) AS
PARENT ON (VL.PARENT_ID = PARENT.VCS_LOCATION_ID)
WHERE COALESCE(B.FULL_KEY, VLX.PLAN_KEY, PARENT.PLAN_KEY) is not NULL ;
MS SQL Server
Click here for query...
SET QUOTED_IDENTIFIER ON
SELECT COALESCE(VL.NAME, VLX.NAME, PARENT.NAME) AS REPO_NAME,
COALESCE(B.FULL_KEY, VLX.PLAN_KEY, PARENT.PLAN_KEY) AS PLAN_KEY,
COALESCE(B.BUILD_TYPE, VLX.BUILD_TYPE, PARENT.BUILD_TYPE) BUILD_TYPE,
COALESCE(B.TITLE, VLX.PLAN_TITLE, PARENT.PLAN_TITLE) TITLE,
COALESCE(VLX.REPOSITORY_TYPE, PARENT.REPOSITORY_TYPE) AS REPO_TYPE,
COALESCE(VLX.XML, PARENT.XML) AS BRANCH
FROM VCS_LOCATION AS VL
LEFT JOIN PLAN_VCS_LOCATION AS PVL ON PVL.VCS_LOCATION_ID = VL.VCS_LOCATION_ID
LEFT JOIN BUILD AS B ON PVL.PLAN_ID = B.BUILD_ID
LEFT JOIN
(select B.FULL_KEY as PLAN_KEY,
BUILD_TYPE,
B.TITLE as PLAN_TITLE,
VL.PLUGIN_KEY as REPOSITORY_TYPE,
VL.VCS_LOCATION_ID,
CAST(
REPLACE(CAST(XML_DEFINITION_DATA AS VARCHAR(MAX)), 'encoding="UTF-8"', 'encoding="utf-8"')
AS XML).value('(//vcsBranch[@class="com.atlassian.bamboo.plan.branch.VcsBranchImpl"]/name)[1]', 'NVARCHAR(max)') as XML,
VL.NAME
from VCS_LOCATION VL
left join PLAN_VCS_LOCATION as PVL on PVL.VCS_LOCATION_ID = VL.VCS_LOCATION_ID
left join BUILD as B on PVL.PLAN_ID = B.BUILD_ID) VLX
ON (VLX.VCS_LOCATION_ID = VL.VCS_LOCATION_ID)
LEFT JOIN
(select B.FULL_KEY as PLAN_KEY,
BUILD_TYPE,
B.TITLE as PLAN_TITLE,
VL.PLUGIN_KEY as REPOSITORY_TYPE,
VL.VCS_LOCATION_ID,
CAST(
REPLACE(CAST(XML_DEFINITION_DATA AS VARCHAR(MAX)), 'encoding="UTF-8"', 'encoding="utf-8"')
AS XML).value('(//vcsBranch[@class="com.atlassian.bamboo.plan.branch.VcsBranchImpl"]/name)[1]', 'NVARCHAR(max)') as XML,
VL.NAME
from VCS_LOCATION VL
left join PLAN_VCS_LOCATION as PVL on PVL.VCS_LOCATION_ID = VL.VCS_LOCATION_ID
left join BUILD as B on PVL.PLAN_ID = B.BUILD_ID)
PARENT ON (VL.PARENT_ID = PARENT.VCS_LOCATION_ID)
WHERE COALESCE(B.FULL_KEY, VLX.PLAN_KEY, PARENT.PLAN_KEY) is not NULL ;
Oracle
Click here for query...
SELECT COALESCE(VL.NAME, VLX.NAME, PARENT.NAME) AS REPO_NAME,
COALESCE(B.FULL_KEY, VLX.PLAN_KEY, PARENT.PLAN_KEY) AS PLAN_KEY,
COALESCE(B.BUILD_TYPE, VLX.BUILD_TYPE, PARENT.BUILD_TYPE) BUILD_TYPE,
COALESCE(B.TITLE, VLX.PLAN_TITLE, PARENT.PLAN_TITLE) TITLE,
COALESCE(VLX.REPOSITORY_TYPE, PARENT.REPOSITORY_TYPE) AS REPO_TYPE,
COALESCE(VLX.XML, PARENT.XML) AS BRANCH
FROM VCS_LOCATION AS VL
LEFT JOIN PLAN_VCS_LOCATION AS PVL ON PVL.VCS_LOCATION_ID = VL.VCS_LOCATION_ID
LEFT JOIN BUILD AS B ON PVL.PLAN_ID = B.BUILD_ID
LEFT JOIN
(select B.FULL_KEY PLAN_KEY,
B.TITLE TITLE,
VL.PLUGIN_KEY REPOSITORY_TYPE,
XMLTYPE(XML_DEFINITION_DATA).EXTRACT('//vcsBranch[@class="com.atlassian.bamboo.plan.branch.VcsBranchImpl"]/name/text()').getStringVal() BRANCH,
from VCS_LOCATION
left join PLAN_VCS_LOCATION PVL on PVL.VCS_LOCATION_ID = VL.VCS_LOCATION_ID
left join BUILD B on PVL.PLAN_ID = B.BUILD_ID) VLX
ON (VLX.VCS_LOCATION_ID = VL.VCS_LOCATION_ID)
LEFT JOIN
(select B.FULL_KEY PLAN_KEY,
B.TITLE TITLE,
VL.PLUGIN_KEY REPOSITORY_TYPE,
XMLTYPE(XML_DEFINITION_DATA).EXTRACT('//vcsBranch[@class="com.atlassian.bamboo.plan.branch.VcsBranchImpl"]/name/text()').getStringVal() BRANCH,
from VCS_LOCATION
left join PLAN_VCS_LOCATION PVL on PVL.VCS_LOCATION_ID = VL.VCS_LOCATION_ID
left join BUILD B on PVL.PLAN_ID = B.BUILD_ID) PARENT
ON (VL.PARENT_ID = PARENT.VCS_LOCATION_ID)
WHERE COALESCE(B.FULL_KEY, VLX.PLAN_KEY, PARENT.PLAN_KEY) is not NULL ;
Last modified on Mar 22, 2022
関連コンテンツ
- 関連コンテンツがありません
Powered by Confluence and Scroll Viewport.