Confluence Template for Service Applications - The Macros

In part one of this article Confluence Template for Service Applications I showed how we used Confluence templates and Jira to keep track all the details for our service applications such as; servers, installation configuration, down times, upgrades, and disruptions. I promised some code ... very little code and here it is. Below are the user macros that we created. These are simply wrappers around the built-in Jira macros. However, the really important part of these is how to dynamically have the macro point to whatever page it is put on without requiring one to change the macro's JQL. There are three variable parts of these macros that are specific to your systems; {Your JIRA Server}, {Your App ID}, and {Your Server ID}. Let's see how to get them.

{Your JIRA Server} and {Your Server ID}

These two are pretty easy to find. Simply create a confluence page and put the Jira macro on the page, or find a page that already has it. If you are creating a page put in a simple JQL query such as issuetype=task, click the search button (looks like a magniying glass), and then click the insert button (looks like a button that says Insert). You need to view the storage format for this macro. If you have the Confluence Source Editor you can use that, otherwise save the page. Once you have the page saved click on the ellipsis menu in the top right corner of you page and select View Storage Format. This will show you the sudo html that makes up you Confluence page. It will look something like this.

Storage-curl.png

The {Your JIRA Server} part is the grayed out section in the red box above in between the <ac:parameter ac:name="server"> and its closing element. The {Your Server ID} part is the grayed out section in the blue box between the <ac:parameter ac:name="serverId"> and its closing element. That was easy peasy!

{Your App ID}

This one is the app id for Confluence that is inside Jira. You can get that by going to Jira Administration -> Applications -> Application links. The url should be http(s)://{Your jira Server}/plugins/servlet/applinks/listApplicationLinks. Click on the edit button for the Confluence application link. In your url bar you will see the id for the Confluence application link. It is the hyphenated letters and number after the "/edit/" in the url.

All done

That's it! You now how the all parts you need to fill in the user macros below. If you are a Confluence administrator you can create a user macro in Confluence Administration -> Configuration -> User Macros.

Now the JQL prior to "AND issue in (issuesWithRemoteLinksByGlobalId('appId={Your App ID}&pageId=$content.id" in the below user macros is obviously specific to how we have it in our Jira system. Your project names and issue types will indeed be different than ours. You would need to adjust it to fit your needs. The import part though is that once you have the {Your App ID} portion filled in with your Confluence application link id the $content.id portion will be dynamically changed based on whatever page you put the user macro on. So it will look for any Jira issues matching your JQL linked to "this" page.

 

I hope you find this as useful as we have. If you have any questions or comments feel free to leave them in the comment section below.

 

Jira Issue Links User Macro

Macro Name:
jira_issue_links

Macro Title:
Jira Issue Links

Description:
Issues in Jira linked to this Confluence page.

Macro Body Processing:
No macro body

Template:

## Developed by: Davin Studer
## Date created: 06/28/2018
## @noparams

<ac:structured-macro ac:name="jira" ac:schema-version="1">
<ac:parameter ac:name="server">{Your JIRA Server}</ac:parameter>
<ac:parameter ac:name="columns">key,type,summary,created,status,assignee,reporter</ac:parameter>
<ac:parameter ac:name="maximumIssues">1000</ac:parameter>
<ac:parameter ac:name="jqlQuery">project = OPS AND issue in (issuesWithRemoteLinksByGlobalId('appId={Your App ID}&pageId=$content.id'))</ac:parameter>
<ac:parameter ac:name="serverId">{Your Server ID}</ac:parameter>
</ac:structured-macro>

 

Jira Server Links User Macro

Macro Name:
jira_server_links

Macro Title:

Jira Server Links

Description:

Servers in Jira linked to this Confluence page.

Macro Body Processing:

No macro body

Template:

## Developed by: Davin Studer
## Date created: 06/28/2018
## @noparams

<ac:structured-macro ac:name="jira" ac:schema-version="1">
<ac:parameter ac:name="server">{Your JIRA Server}</ac:parameter>
<ac:parameter ac:name="columns">summary,Production Status</ac:parameter>
<ac:parameter ac:name="maximumIssues">1000</ac:parameter>
<ac:parameter ac:name="jqlQuery">project = ASSETS AND issuetype = Server AND status = "In Service" AND issue in (issuesWithRemoteLinksByGlobalId('appId={Your App ID}&pageId=$content.id'))</ac:parameter>
<ac:parameter ac:name="serverId">{Your Server ID}</ac:parameter>
</ac:structured-macro>

 

2 comments

Hi Davin,

thanks for your inspiration with this post! This is nice when you manually create links between tickets and pages.

We are struggling in creating automated links from Confluence with Jira as we do not know how to get the AppID of Jira from Confluence. Do you have an approach here?

Regards,
Thomas

Davin Studer Community Champion Oct 24, 2018

If you go to Confluence Administration -> Application Links and edit the app link to Jira it will be in your URL bar. The url will look something like this ...

https://{your server}/plugins/servlet/applinks/edit/{AppID}

Comment

Log in or Sign up to comment
Community showcase
Published Dec 18, 2018 in Confluence Cloud

Happy holidays from our team to yours!

Hi Community!  2018 was filled with changes for our team, both big and small, and we've taken a lot of time to both celebrate our wins and recognize areas of improvement. One thing that we're a...

456 views 3 18
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you