Jira Gadgets fail to load in Confluence with a "Error rendering macro 'gadget'" error
プラットフォームについて: 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 は除く
要約
Jira Gadgets are not working in Confluence with the following error:
Error rendering macro 'gadget'
The gadget at http://charlie.atlassian.net/rest/gadgets/1.0/g/com.pyxis.greenhopper.jira:greenhopper-gadget-sprint-health/gadgets/greenhopper-sprint-health.xml was not added to this Confluence instance yet.
The Sprint Health Gadget was used as an example here, but other Jira Gadgets can be affected the same way.
環境
Confluence Server and Data Center.
診断
- There is a valid Application Link connecting Confluence and Jira.
- Jira is registered in Confluence as an External Gadget Feed.
- The error mentions a URL that does not match Jira's current Base URL.
原因
The Jira server or data center 'base URL' has changed (possibly due to a migration) but the macro references were not updated to the new URL in Confluence.
ソリューション
Update the affected macros with a valid 'base URL' so it points to the current Jira server or data center instance.
Option 1 - Source Editor
If only a handful of macros need to be fixed, using the Confluence Source Editor* app is the quickest and safest approach.
Although the Marketplace page mentions the Confluence Source Editor is for Confluence Server only, it can be installed in Confluence Data Center instances and should work as well.
In order to do that:
- Install the Confluence Source Editor app in your Confluence server/data center.
- Navigate to the affected page and select Edit at the top of the page.
- Select the Open in source editor button ('<>' symbol in the upper-right corner).
- Locate the <ac:parameter ac:name="url"> parameter.
- Replace the invalid URL with the correct one. For the example, we should replace 'charlie.atlassian.net' with a new URL that points to the correct Jira Server/Data Center endpoint.
- Click Apply then Update
- Refresh the page.
Here's an example of how the Sprint Health Gadget looks in Storage Format:
<p>
<ac:structured-macro ac:macro-id="a1523271-9080-40f9-8c0f-aa234f7f0b0e" ac:name="gadget" ac:schema-version="1">
<ac:parameter ac:name="preferences">rapidViewId=1&showRapidViewName=true&sprintId=1&showSprintName=true&showAssignees=false&isConfigured=true&refresh=15&=false</ac:parameter>
<ac:parameter ac:name="url">http://charlie.atlassian.net/rest/gadgets/1.0/g/com.pyxis.greenhopper.jira:greenhopper-gadget-sprint-health/gadgets/greenhopper-sprint-health.xml</ac:parameter>
</ac:structured-macro>
</p>
Option 2 - Database Manipulation
Find-Replace operation
A 'Find-Replace' operation on the database may be necessary if several macros need to be fixed.
Make sure to back up your database before performing any changes! We strongly recommend testing this approach on a testing or staging environment before implementing the changes in production!
To change the URL in the database to another URL:
- Confluence を停止します。
- Create a backup of Confluence's database. Save somewhere offsite for safekeeping.
Run the following SQL query on Confluence's database:
UPDATE BODYCONTENT SET body = replace(body,'old-url','new-url') WHERE body LIKE '%old-url%';
- Verify that the bodycontent table now has the new url.
- Confluence を起動します。
Specific URL reference
In order to change Macro references only, we suggest using a more targeted UPDATE statement. For instance, in step 3 above, use this SQL UPDATE statement instead:
UPDATE BODYCONTENT
SET body = replace(body,'<ac:parameter ac:name="url">http://charlie.atlassian.net','<ac:parameter ac:name="url">http://jira.charlie.com')
WHERE body LIKE '%<ac:parameter ac:name="url">http://charlie.atlassian.net%';
This will replace http://charlie.atlassian.net with http://jira.charlie.com.
Using the UPDATE statements will replace ALL references to the old URL, including plain-text entries in Pages, Comments and Blog posts in the database.