Example: Get Jira Issue Information on a Confluence Page
You can create a macro to pull Jira issue information onto your Confluence page.
Create the macro
- Select the Settings cog in the top right-hand corner of the screen.
- Select Macros under ScriptRunner.
- Select Create Custom Macro.
- Enter a Name to identify the Macro, like Jira Issue Information.
- Enter an optional Description, like Get the issue ID and issue summary on your Confluence page.
- Select Enabled to allow the macro to be added to pages.
- Select None for Body Type.
- Pick Block for Output Type.
Enter the following script into the Script to Execute field:
groovydef issue = get("/rest/api/3/issue/${parameters.issueID}") .asObject(Map) .body String text = "<H1>project name "+issue.fields.project.name+"</H1><br>" + "<H3>issue ID ${issue.key} </h2> <br>" + "<H3>issue Summary : ${issue.fields.summary} </h2>" return text
- Select Add Parameter.
- When the window appears, fill out the following fields:
- Type: String
- Name: issueID
- Description ID: Issue ID
- Check the box for Required.
- Click Save.
- When the window appears, fill out the following fields:
- Select Save.
The macro immediately appears on the main Macros page:
Users in your instance can now add it to Confluence pages. When it's added, the user sees the issueID parameter, where they enter the issue ID.
Once an issue ID is added to the field and the page is saved, the macro appears like this: