Jira Issue/Filter macro update with Script Runner, but filter what to update

Illés Ákos January 10, 2025

We decided to move a project from our Data Center Jira instance to cloud in a Jira Service Management instance and we would like to set the mentions in confluence also to the cloud instance project, so we would need a way to update all the Jira Issue/Filter macros to point to cloud instead of the Data Center project. The problem is that other projects which are mentioned in confluence are not migrated to cloud, so those ones should not be updated. The only solution I found is Script Runner update macro built-in script, but without a console script it would update all the macros it finds. It is not exactly clear how to check what the parameters are in the macro.

Here is my code so far(obviously it doesn't work):

 

import com.atlassian.confluence.xhtml.api.MacroDefinition

macroTransform = { MacroDefinition macro ->

    String url = macro.getParameter('confluence.extra.jira.jira.param.serverUrl.label')

    String keyLabel = macro.getParameter('confluence.extra.jira.jira.param.key.label')

    String newURL = 'MYCOMPANYCLOUDURL'

   

    if (keyLabel.contains('XYZ-')) {

        macro.setParameter('confluence.extra.jira.jira.param.serverUrl.label', url.replace('MYCOMPANYDCURL', newURL))

    }

    macro

}
Any help or input would be much appreciated!

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events