Some prerequisites:

  • Jira & Confluence must be Server (no Cloud) because we use the HTML Macro to insert Javascript and Ajax
  • Jira & Confluence must have SSO enabled (Single Sign On). For example, using Atlassian Crowd.

 Recipe:

  • Create a Confluence Server Page
  • Add the HTML Macro and insert something like this:

Captura de pantalla 2018-05-12 a las 19.55.34

The first Div is to create an input-box and a button to search some Jira ticket. Are the input params.

The second Div is to show the Jira ticket field information.

We can add a Javascript Ajax Rest web service query to obtain the Jira ticket info.

function getIssue(key)
{
	 AJS.$.ajax({
        url: "/rest/api/2/issue/" + key,
        type: 'get',
        dataType: 'json',
        async: false,
        success: function(data) {
            issue = data;
        }
     });

	$('#ticket').html($('#ticket').html() + "
<b>Summary:</b>" + issue.fields.summary );
	$('#ticket').html($('#ticket').html() + "
<b>Description:</b>" + issue.fields.description);
	return issue;
}

To finish we insert the last script tag HTML.
Captura de pantalla 2018-05-12 a las 19.55.43
Then we publish the Confluence page and we start the tests! (very easy)

Captura de pantalla 2018-05-12 a las 19.54.46

Making some tests….

Captura de pantalla 2018-05-12 a las 19.54.25
It works fantastic! 🙂 and also is permission-level protected!

That’s all!

By MrAddon.

Advertisements
Posted by:.

One thought on “How to show Jira ticket fields in Confluence pages

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s