Confluence groovy script or macro to pull linked jira issue key and summary

SJ March 17, 2022

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

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

 

Thanks

-SJ

2 answers

1 vote
Florian Bonniec
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 19, 2022

Hi @SJ 

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

0 votes
Craig Nodwell
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 17, 2022

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.

SJ March 17, 2022

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.

Like Craig Nodwell likes this
Craig Nodwell
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 17, 2022

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.

SJ March 17, 2022

(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.pngwhen 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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events