How to locate Plans with disabled Plan Branch cleanup settings in Bamboo


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

サーバー*製品のサポートは 2024 年 2 月 15 日に終了しました。サーバー製品を利用している場合は、アトラシアンのサーバー製品のサポート終了のお知らせページにて移行オプションをご確認ください。

*Fisheye および Crucible は除く

本記事で説明している手順は、現時点でのものとなります。そのため、一部のお客様で特定の状況下で動作したという報告がありますが、正式にサポートされているわけではなく、お客様の特定のシナリオで動作することを保証するものではありません。

本番環境での実施の前に一通り非本番環境で検証し、成功しなかった場合にはサポートされている代替案にフォール バックしてください。

また、アトラシアン サポートのサポート対象外のご質問の場合には、Community もご活用ください。

要約

Bamboo will not enable any Plan Branch cleanup policy by default, meaning that every Plan Branch that is created from a Repository Branch in Bamboo will not be cleaned unless instructed. This is to prevent Plan branches from being deleted without further notice. It is up to each Development Team and Bamboo Administrators to define a policy that would better fit into each company's rules and add custom "Delete plan branch" settings on a per-plan basis. It is also advisable to communicate this behaviour to all Development teams so they can work on adjusting their Plans and have a better Plan branch removal policy.

This is also documented on Bamboo Specs:

Just like the UI settings, the default behaviour for Specs changes is to not set any immediate destructive setting, including Plan Branch expiry/deletion.

環境

Bamboo 7, 8, 9

ソリューション

Bamboo will not provide you with a reporting interface where you can search for such settings. For that, we recommend you run some SQL statements to find the information you are looking for.

The SQL below will return every Plan that has a disabled Plan branch clean-up setting and their current settings.

The provided SQL instructions were tested only on PostgresSQL. You may have to adapt the queries for other databases.

Building SQL statements for reporting purposes is not part of the Atlassian Support scope and this work is provided "as-is", on a best-effort basis. Queries may work better or worse than expected, your mileage may vary. It is up to each customer to analyze each query individually and understand if that is enough for their specific needs.

SELECT   *
FROM     (  SELECT B.FULL_KEY,
                   B.TITLE,
                   CAST((XPATH('//branches/branchRemovalCleanUpEnabled/text()', CAST(BD.XML_DEFINITION_DATA AS XML)))[1] AS TEXT)::BOOLEAN  AS "Branch_Removal_Cleanup",
                   CAST((XPATH('//branches/inactiveBranchCleanupEnabled/text()', CAST(BD.XML_DEFINITION_DATA AS XML)))[1] AS TEXT)::BOOLEAN AS "Inactive_Branch_Removal",
                   CAST((XPATH('//branches/removalCleanupPeriodInDays/text()', CAST(BD.XML_DEFINITION_DATA AS XML)))[1] AS TEXT)::INT       AS "Removal_Cleanup In Days",
                   CAST((XPATH('//branches/inactivityInDays/text()', CAST(BD.XML_DEFINITION_DATA AS XML)))[1] AS TEXT)::INT                 AS "Inactivity_in_Days"
            FROM   BUILD B
            JOIN   BUILD_DEFINITION BD
              ON   BD.BUILD_ID = B.BUILD_ID
           WHERE   B.BUILD_TYPE = 'CHAIN' ) A
WHERE    (
            "Branch_Removal_Cleanup" IS FALSE
         OR "Inactive_Branch_Removal" IS FALSE )
ORDER BY FULL_KEY

Example output

Full_keytitleBranch_Removal_CleanupInactive_Branch_RemovalRemoval_Cleanup In Days

Inactivity_in_Days

ABC-AGArtifact GeneratorTRUEFalse830
ABC-DFGDFGTRUEFalse230
ABC-ELELASTICFalseFalse730
ABC-FAILFAILFalseFalse730
ABC-WINWINFalseFalse730
DEF-AD追加内容FalseFalse730
DEF-BB6BB6FalseFalse129
DEF-BIGBIGFalseFalse730
DEF-BREAKBREAKFalseFalse730
DEF-DEFDEFFalseFalse730
DEF-GRADGRADFalseFalse730
DEF-JIRAJiraFalseFalse730
DEF-TSTEST SpecsTRUEFalse230

After having a list of Plans with disabled Branch clean-up settings, you can either update them by editing each Plan under the "Branches" tab or use Specs for a programmatic change.

If the provided SQL fails with XML syntax errors, try the following query that doesn't use XPATH. It will return Branch_Removal_Cleanup and Inactive_Branch_Removal. Finding each policy numbers will need to be parsed on each Plan settings individually:

SELECT *
FROM   (SELECT B.FULL_KEY,
               B.TITLE,
               CASE
                 WHEN BD.XML_DEFINITION_DATA LIKE
                  '%<branchRemovalCleanUpEnabled>false</branchRemovalCleanUpEnabled>%' THEN 'false'
                 ELSE 'true'
               END AS "Branch_Removal_Cleanup",
               CASE
                 WHEN BD.XML_DEFINITION_DATA LIKE
                  '%<inactiveBranchCleanupEnabled>false</inactiveBranchCleanupEnabled>%' THEN 'false'
                 ELSE 'true'
               END AS "Inactive_Branch_Removal"
        FROM   BUILD B
               JOIN BUILD_DEFINITION BD
                 ON B.BUILD_ID = BD.BUILD_ID
        WHERE  B.MARKED_FOR_DELETION IS NOT NULL
               AND B.BUILD_TYPE = 'CHAIN') A
WHERE  ( "Branch_Removal_Cleanup" = 'false'
          OR "Inactive_Branch_Removal" = 'false' )
ORDER  BY FULL_KEY

最終更新日: 2023 年 1 月 30 日

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

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