Customising Page Info
Introduction
To extend the macro users should have basic java or groovy knowledge. In Page Info users can extend the Information Type by overriding the "setCustomVariables" method.
Instructions
The following example adds "Page Reviewer" and "Page Approved By" Information Type in the newly extended macro.
-
Navigate to your script root. Default is <Confluence>/home/scripts. More information about script roots.
-
Create the package com.onresolve.scriptrunner.canned.confluence.macros in your script root.
-
Navigate to the package specified above and inside the macros folder create a new groovy class "CustomPageInformationMacro.groovy" that extends the old class and overrides the setCustomVariables method. A descriptive class name is recommended.
-
Disable the old macro in the Script Macros section in Confluence. Enable the new macro in the same section. The names of the macros will be the same as to not break any macros already used.
-
Populate the class:
package com.onresolve.scriptrunner.canned.confluence.macros
class CustomPageInformationMacro extends PageInformationMacro {
@Override
protected Map<String, String> setCustomVariables() {
//set the custom value
def customVariables = [:]
customVariables.put("Page Reviewer", "George Washington")
customVariables.put("Page Approved By", "Abraham Lincoln")
customVariables
}
}
-
Disable the old macro and enable the new macro in the Script Macros section in Confluence (the names of the macros will be the same as to avoid breaking any macros already in use).
-
The added information type should be available in the information type list.
For how-to questions please ask on Atlassian Answers where there is a very active community. Adaptavist staff are also likely to respond there.
Ask a question about ScriptRunner for JIRA, for for Bitbucket Server, or for Confluence.