Raw XML Module Breaking Change for Bitbucket 9
The raw XML format for condition class and provider class has changed with Bitbucket 9.0.0. The formats previously generated from the Preview button for each of the following built-in fragment scripts are no longer valid:
If you previously created a fragment using the raw XML generated from the Preview button, you need to manually update it to the new format for your fragment to function correctly. You can find the following information about this breaking change:
Fragment XML conditions and web panel class scripts are now provided via XML parameters and are no longer directly set as the condition class element attribute or web panel class element attribute value. Use this guide to help you convert your scripts to the new fragment XML parameters format.
Examples of the old Raw XML format
Below are examples of raw XML scripts that will no longer work and will need to be updated.
Web Items
Inline script:
<web-item key='test-key' name='ScriptRunner generated web item - test-key' section='header.global.primary' weight='1'>
<label>Test</label>
<condition class='script:def someVar = "foo" true'>
<param name='£trackingParameters' value='{"scriptName":"com.onresolve.scriptrunner.canned.bitbucket.fragments.CustomWebItem"}' />
<param name='£fragmentParameters' value='{"id":"004779ea-8037-4d00-9f49-ee8ead340588"}' />
</condition>
<styleClass> test-key </styleClass>
<link linkId='test-key'>http://www.google.com?_=1</link>
</web-item>Script file:
<web-item key='test-key' name='ScriptRunner generated web item - test-key' section='header.global.primary' weight='1'>
<label>Test</label>
<condition class='myConditions/fooCondition.groovy'>
<param name='£trackingParameters' value='{"scriptName":"com.onresolve.scriptrunner.canned.bitbucket.fragments.CustomWebItem"}' />
<param name='£fragmentParameters' value='{"id":"004779ea-8037-4d00-9f49-ee8ead340588"}' />
</condition>
<styleClass> test-key </styleClass>
<link linkId='test-key'>http://www.google.com?_=1</link>
</web-item>Web Panels
Inline script:
<web-panel key='test-one' name='ScriptRunner generated web panel - test-one' location='bitbucket.notification.banner.header' weight='1' class='script:writer.write("Hello world!")'>
<label>Test Panel</label>
<condition class='script:true'>
<param name='£trackingParameters' value='{"scriptName":"com.onresolve.scriptrunner.canned.bitbucket.fragments.CustomWebPanel"}' />
<param name='£fragmentParameters' value='{"id":"bc6290db-0e01-4b2f-8f26-1e0e478df588"}' />
</condition>
<param name='lazy' value='true' />
</web-panel>Script file:
<web-panel key='test-one' name='ScriptRunner generated web panel - test-one' location='bitbucket.notification.banner.header' weight='1' class='myPanels/myPanelScript.groovy'>
<label>Test Panel</label>
<condition class='myConditions/fooCondition.groovy'>
<param name='£trackingParameters' value='{"scriptName":"com.onresolve.scriptrunner.canned.bitbucket.fragments.CustomWebPanel"}' />
<param name='£fragmentParameters' value='{"id":"bade0156-7b0c-41af-b42d-7be285822c24"}' />
</condition>
<param name='lazy' value='true' />
</web-panel>Find the broken raw XML fragments
After you upgrade ScriptRunner for Bitbucket and you still have the outdated raw XML fragments, ScriptRunner for Bitbucket shows errors in the logs when ScriptRunner is enabled. Each error starts with this message:
Execution of Fragment script failed with errorThen the error message describes why it failed and gives a link to where you can edit the failing fragment.
Edit the broken fragment here: <URL Link to edit the broken fragment>The broken raw XML fragments will still show as active in the ScriptRunner UI fragments page, but they will not be functional.
Fix the broken raw XML fragments
Use the log output to find which raw XML fragments need to be fixed. Every time you edit or create a fragment, all fragments are re-registered, so you will see the log error messages every time you make changes until all invalid fragments have been fixed.
We suggest these steps to fix broken raw XML fragments:
See below for detailed examples for each type of UI fragment.
Example: Fix a broken raw XML fragment in a web item
Let's say that you have the following web item script in your instances with the broken raw XML format:
<web-item key='test-key' name='ScriptRunner generated web item - test-key' section='header.global.primary' weight='1'>
<label>Test</label>
<condition class='script:def someVar = "foo" true'>
<param name='£trackingParameters' value='{"scriptName":"com.onresolve.scriptrunner.canned.bitbucket.fragments.CustomWebItem"}' />
<param name='£fragmentParameters' value='{"id":"004779ea-8037-4d00-9f49-ee8ead340588"}' />
</condition>
<styleClass> test-key </styleClass>
<link linkId='test-key'>http://www.google.com?_=1</link>
</web-item>Follow these steps to fix it:
Example: Fix a broken raw XML fragment in a web section
The process for migrating web sections is the same as for web items. Follow these steps:
- Fill out the Create a Custom web section form, referring to the old broken raw XML for the form field values.
- Click the preview button to get the new XML.
- Add the missing extra elements shown in Add the missing extra elements in the web item steps above.
- Add the condition back to the XML (remember to use the converter script to convert your inline scripts to the new format).
Example: Fix a broken raw XML fragment in a web panel
Let's say that you have the following web panel script in your instances with the broken raw XML format:
<web-panel key='test-one' name='ScriptRunner generated web panel - test-one' location='bitbucket.notification.banner.header' weight='1' class='script:writer.write("This is HTML that my web panel generates!")'>
<label>Test Panel</label>
<condition class='script:true'>
<param name='£trackingParameters' value='{"scriptName":"com.onresolve.scriptrunner.canned.bitbucket.fragments.CustomWebPanel"}' />
<param name='£fragmentParameters' value='{"id":"bc6290db-0e01-4b2f-8f26-1e0e478df588"}' />
</condition>
<param name='lazy' value='true' />
</web-panel>The process for migrating a web panel's raw XML is the same as for web items when migrating the conditions element, but also requires one extra step to migrate the web panel provider class.
Follow these additional steps to migrate the provider class script: