Confluence groovy script or macro to pull linked jira issue key and summary
Asked by SJ:

I need help finding information for confluence groovy scripting.

When a confluence page is linked to a Jira issue this button shows up on the page

![image.png](/t5/image/serverpage/image-id/188681i97B492D6E05E5E19/image-size/large?v=v2&px=999 "image.png")

Within Confluence can I use groovy to get the Issue key and summary to display a text field or Jira link macro?

I would like to be able to see the Jira linked issues listed out like the card here when you click the Jira link button above

![image.png](/t5/image/serverpage/image-id/188687iB4A71D37C58719F9/image-size/large?v=v2&px=999 "image.png")

Thanks

-SJ


Answers:
author: Florian Bonniec
body: Hi [@SJ](/t5/user/viewprofilepage/user-id/4475435)

The only way I found to achieve that is to do a REST Call to get this information.  
The endpoint to use from Confluence is "/rest/jira-metadata/1.0/metadata?pageId="

It will return a JSON with "groups", one of them is of type Issues and list all issues linked to the page.

Regards


author: Craig Nodwell
body: This might be a bit complicated but you should be able to accomplish this, although I think you need to break down your requirements a bit.   
Ex: How are the links being made? re: Jira macro, Confluence Link in Jira Issue, URL copy/paste into Confluence page.  
It has been my experience when publishing Jira data into confluence it is easier to push from Jira than to pull from confluence. With that in mind., you'll need to setup a listener, use your application links for access, listen for when new links are created, validate to ensure the links are of type confluence, get the space \& page id, formulate your content, publish.  
Now on the other side you could create a custom macro/listener combo to pull the data and publish an update based on the first existence or edit of a Jira link, I think the easiest way to do that would be via the scriptrunner plugin and setup a rest endpoint or resource to the jira database to feed into the custom macro.  
I have some script examples that could get you going depending on the course of action you wish to take but keep in mind this will not be easy and will have a maintenance overhead.

comments: author: SJ
body: Here's a bit more detail

We use AutoPage in Jira to create Confluence documentation pages for specific issue types. That is how the Confluence links are created.

This Icon/button is dynamically rendered at the top of a page if that page is linked to by a Jira Issue and is built in Confluence functionality

I'm looking for a Confluence macro/script to show me all the Jira Issues that reference that Confluence page.


author: Craig Nodwell
body: I don't have experience with that plugin, however the documentation shows it's very customizable as to what gets published. Maybe you might want to explore that a bit more if possible, re: maybe a second publish with different details(template) based on the initial publish....

Quick question, do these get published to a singular page? or individual pages? just wondering based on your last sentence. The answers may help with further breaking down requirements.


author: SJ
body: (Edited for clarity)

We use autopage to create single doc pages from Jira as well as multipage hierarchies.

How the Confluence pages are created shouldn't make much difference. The fact the page is linked in a Jira issue and somehow a Confluence page knows to display this icon ![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/188726i15DAB3B3DA88EF29/image-size/large?v=v2&px=999 "image.png")when that link exists.

I want to be able to expand that connection to get and display a bit more information about the Jira issues referencing the confluence page.


Tags: confluence-server

server