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

Thomas Egger October 24, 2018

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
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 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
TAGS
AUG Leaders

Atlassian Community Events