It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to link Jira issue with confluence page with scriptrunner

Hello everyone

i am using Jira and confluence cloud.
i have post function which creates Confluence page, and it is code written in Scriptrunner.
nextly i want to automatically link this issue to newly created confluence page .

anny suggestions?

2 answers

1 accepted

1 vote
Answer accepted
Derek Fields Community Leader Nov 12, 2019

When I do this in my cloud environment, I get the following macro code:

<ac:structured-macro ac:name="jira" ac:schema-version="1" ac:macro-id="ab120ae6-a585-4b2f-a713-4d23b355dc17">
<ac:parameter ac:name="server">System JIRA</ac:parameter>
<ac:parameter ac:name="columns">key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution</ac:parameter>
<ac:parameter ac:name="serverId">f4829001-734e-3f21-9592-1239fa2ab525</ac:parameter>
<ac:parameter ac:name="key">SVCD1-26</ac:parameter>

This is the code that you need to put into the Scriptrunner page creation code. You will need to update the text pieces, such as the Issue Key

I worked Derek ! Thank you very much!
I Put  my Cloud my serverID in the serverID parameter and it worked.
thank you very much again!

Derek Fields Community Leader Nov 12, 2019

Would you accept the answer? This will let others know that the question has been answered.

Like Dachi Peradze likes this

Yes! I voted up for answer already . Thank you again 

0 votes
Derek Fields Community Leader Nov 11, 2019

You simply need to add the macro code into the template content.  The easiest way to get the content code is to insert a Jira macro into a test page and then look at the source format. You will see something like this:

<ac:structured-macro ac:macro-id="75aa2d99-580c-4f90-acf8-1af6548ef9d8" ac:name="jira" ac:schema-version="1">
<ac:parameter ac:name="server">localhost JIRA</ac:parameter>
<ac:parameter ac:name="columns">key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution</ac:parameter>
<ac:parameter ac:name="serverId">24fa42dc-2a9d-3954-8878-59c90d00a3d0</ac:parameter>
<ac:parameter ac:name="key"><ISSUE KEY></ac:parameter>

 put this text into your body content, replacing the <ISSUE KEY> with the actual issue key (e.g., $issue.key). This will cause the macro to be part of the new page.

Hello Derek.
I Couldnt find a way to add macro in confluence page. there is no such option for my cloud confluence.
what can be the reason?

Derek Fields Community Leader Nov 12, 2019

When you edit a Confluence page, you should be able to insert a Jira macro by clicking on the macro menu, which is the + sign on the upper right of the menu. You should see Jira Issue/Filter macro. Click on that and then insert you Jira issue there. Once you have done that, you need to view the source format to get the actual body content that you need to add to your ScriptRunner script.

I did it but on cloud it has different format

it is in Divs and spans, which has unique id s whit them, do you know how to work with that?

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you