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

  1. Select the Settings cog in the top right-hand corner of the screen. 
  2. Select Macros under ScriptRunner
  3. Select Create Custom Macro
  4. Enter a Name to identify the Macro, like Jira Issue Information
  5. Enter an optional Description, like Get the issue ID and issue summary on your Confluence page
  6. Select Enabled to allow the macro to be added to pages. 
  7. Select None for Body Type. 
  8. Pick Block for Output Type. 
  9. Enter the following script into the Script to Execute field: 

    groovy
    def 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
  10. Select Add Parameter
    1. When the window appears, fill out the following fields: 
      1. Type: String
      2. Name: issueID
      3. Description ID: Issue ID
    2. Check the box for Required.
    3. Click Save.

  11. 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: 


On this page