別の Jira インスタンスを示すように Jira 課題マクロを一括更新する方法

お困りですか?

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

コミュニティに質問

プラットフォームについて: 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 は除く

問題

Confluence ページに Jira リンクへの課題を作るには、Jira 課題マクロが使われます。これらのリンクには、リンクが参照する Jira インスタンスの ID が含まれます。

特定の状況において (ドメイン変更、移行、インスタンスの統合など)、これらのリンクを編集して別の Jira インスタンスを指すようにする必要があります。これを行わないと、Confluence ページに次のエラー メッセージが表示されます。

診断

A Jira Issue Macro link contains two identifiers; The Application Link ID and the Application Name. Should you encounter this issue, it is necessary to check if the Application Link ID and the Application Name is pointing to the correct Jira instance.

次の手順を行います。

  1. まず、影響を受けるページに移動して Confluence の保存形式を確認します。
    (info) アプリケーション リンクの ID アプリケーション名の値を記録します。

    ストレージ形式の例
    <p><ac:structured-macro ac:name="Jira" ac:schema-version="1" ac:macro-id="f4b5962b-5cf2-4754-90d9-758306583d18"><ac:parameter ac:name="server">Jira Old</ac:parameter><ac:parameter ac:name="columns">key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution</ac:parameter><ac:parameter ac:name="maximumIssues">20</ac:parameter><ac:parameter ac:name="jqlQuery">project = SP </ac:parameter><ac:parameter ac:name="serverId">79f0263c-a3a5-323b-870c-aea1895cabeb</ac:parameter></ac:structured-macro></p>
    アプリケーション リンクの ID
     <ac:parameter ac:name="serverId">79f0263c-a3a5-323b-870c-aea1895cabeb</ac:parameter>
    アプリケーション名
     <ac:parameter ac:name="server">Jira Old</ac:parameter>
  2. 次に、web ブラウザで次の URL にアクセスすることで、正しいアプリケーション リンク ID アプリケーション名を特定します。

    http://<Jira-Base-URL>/rest/applinks/1.0/manifest

    アプリケーション リンクの ID
     <id>144880e9-a353-312f-9412-ed028e8166fa</id>
    アプリケーション名
     <name>Atlassian Jira</name>
  3. 最後に、ステップ 1 とステップ 2 の両方で特定したアプリケーション リンク ID アプリケーション名を一致させる必要があります。

ID とリンクを見つける別の方法
  • Jira 課題マクロを 2 つ見つけます (同じページで使われているのが望ましいですが、2 つの異なるページでもかまいません)。スペース キーとページ タイトルを覚えておきます。
  • 片方の Jira 課題マクロを編集して JQL を再検索する (虫眼鏡アイコンをクリック) ことで修正します。
    • これで、修正済みのマクロが 1 つと、古いサーバーを指しているマクロが 1 つになります
    • その後、片方はソースの Jira にリンクし、もう片方の現在の Jira にリンクしているものは修正されます
  • Check the XML for the page(s) by either executing the following SQL query (you will need to run once for each page) or viewing the Storage Format of the affected pages.


select body from bodycontent where contentid = (select contentid from content where spaceid = (select spaceid from spaces where spacekey = 'KEY') and title = 'Page Title');


(info) Replace 'KEY' with the affected space key and 'Page Title' with the affected page title.

  • 次のようなものを検索します。
ac:name="server">Jira (source.atlassian.net)</ac:parameter><ac:parameter ac:name="serverId">67806a6b-f924-3896-8e84-fecf05e0398b
  • この例はソース サーバー (修正されていない Jira 課題マクロ) 用のものですが、もう片方についても同様です。
  • "serverId" で、ソースと宛先の両方のサーバー ID をコピーします。

原因

この問題は、影響を受けるページのストレージ形式と宛先の Jira インスタンスとでアプリケーション リンク ID アプリケーション名が異なるために発生します。 

ソリューション

この例では、Jira 課題マクロのリンクを、アプリ リンク ID 79f0263c-a3a5-323b-870c-aea1895cabeb および名前 Jira Old からアプリ リンク ID 144880e9-a353-312f-9412-ed028e8166fa および名前 Atlassian Jira に変更しています。

すべての Jira 課題マクロ情報は、次の例のように BODYCONTENT テーブルに含まれます。

<p><ac:structured-macro ac:name="Jira"><ac:parameter ac:name="columns">key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution</ac:parameter>
<ac:parameter ac:name="server">Jira Old</ac:parameter><ac:parameter ac:name="serverId">79f0263c-a3a5-323b-870c-aea1895cabeb</ac:parameter>
<ac:parameter ac:name="key">TST-1</ac:parameter></ac:structured-macro></p>

If the affected instance is on Confluence 7 or newer, make sure to update the Drafts to use changes on the next opening of the draft, If on the older Confluence version, skip to the update of BODYCONTENT:

UPDATE CONTENTPROPERTIES set stringval='synchrony-recovery' WHERE PROPERTYID in (SELECT cp.PROPERTYID FROM BODYCONTENT bc JOIN CONTENTPROPERTIES cp ON cp.CONTENTID = bc.CONTENTID WHERE bc.BODY like '%<old_string>%' AND cp.PROPERTYNAME = 'sync-rev-source');

BODYCONTENT テーブルの情報を更新するには、次の SQL ステートメントを使用します。

UPDATE BODYCONTENT 
 SET BODY = REPLACE(BODY,'<old_string>','<new_string>');

MSSQL の場合は次のようなクエリを使います。

UPDATE BODYCONTENT
 SET BODY = CAST(REPLACE(CAST(BODY as nvarchar(max)),'<old_string>','<new_string>') as ntext);

ここで、<old_string> は BODY フィールドで探す文字列であり、<new_string> で置き換えられます。


データベースを変更する前には必ずデータをバックアップするようにします。

  1. Confluence 6.x 以降で、共同編集がオンまたは制限付きに設定されている場合、上述のデータベース操作を行う前に共同編集を無効化し、変更後、 Confluence の再起動後に再度有効化します。これは、Synchrony のキャッシュで新しい値を取得できるようにするためです。 

    Per Administering Collaborative Editing, it's a good idea to prompt your users to publish any shared drafts before you turn collaborative editing off, as they will not be able to resume editing existing shared drafts or unpublished changes.

  2. Confluence をシャットダウンします。
  3. 次の SQL アップデート ステートメントを実行します。

    UPDATE BODYCONTENT
    SET BODY = REPLACE(BODY, '<ac:parameter ac:name="server">Jira Old</ac:parameter>',
                       '<ac:parameter ac:name="server">Atlassian Jira</ac:parameter>');
    
    UPDATE BODYCONTENT
    SET BODY = REPLACE(BODY, '<ac:parameter ac:name="serverId">79f0263c-a3a5-323b-870c-aea1895cabeb</ac:parameter>',
                       '<ac:parameter ac:name="serverId">144880e9-a353-312f-9412-ed028e8166fa</ac:parameter>');
    UPDATE BODYCONTENT
     SET BODY = CAST(REPLACE(CAST(BODY as nvarchar(max)),'<ac:parameter ac:name="server">Jira Old</ac:parameter>',
    '<ac:parameter ac:name="server">Atlassian Jira</ac:parameter>') as ntext);
    
    
    UPDATE BODYCONTENT
     SET BODY = CAST(REPLACE(CAST(BODY as nvarchar(max)),'<ac:parameter ac:name="serverId">Jira Old ServerID</ac:parameter>',
    '<ac:parameter ac:name="serverId">Atlassian Jira ServerID</ac:parameter>') as ntext);

    すべてのページに影響を与えたくない場合は条件を追加することもできます。次の SQL クエリは、spacekey - 'KEY' のスペースのコンテンツのみを更新します。

    Spacekey 値を指定する SQL アップデート クエリ
    UPDATE bodycontent
    SET body = replace(body, 'ac:name="server">Jira (source.atlassian.net',
                       'ac:name="server">Jira (destination.atlassian.net')
    where contentid in (select contentid from content where spaceid in (select spaceid from spaces where spacekey = 'KEY'));
    
    UPDATE bodycontent
    SET body = replace(body, 'ac:name="serverId"><source server ID>', 'ac:name="serverId"><destination server ID>')
    where contentid in (select contentid from content where spaceid in (select spaceid from spaces where spacekey = 'KEY'));

  4. Confluence を再起動します。


説明

The Jira Issues Macro is used to create links to Jira issues in Confluence pages.  These links contain the identification of which Jira instance the link refers to.

In some situations, (e.g. domain change, migration, merge instance, etc) it will be necessary to edit these links and point them to a different Jira instance. Otherwise, an error message will be shown on the Confluence page.

製品Confluence
プラットフォームServer
最終更新日 2023 年 4 月 21 日

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

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