Open Navigation

Jira

Plan, track, and manage your agile and software development projects

Overview

Jira is a proprietary issue tracking product developed by Atlassian which allows bug tracking and agile project management.

OAuth1 Authentication

Step 1: Generate an RSA public/private key pair

In a Terminal window, run the following openssl commands (please run the commands separately):

openssl genrsa -out jira_privatekey.pem 1024

openssl req -newkey rsa:1024 -x509 -key jira_privatekey.pem -out jira_publickey.cer -days 365

openssl pkcs8 -topk8 -nocrypt -in jira_privatekey.pem -out jira_privatekey.pcks8

openssl x509 -pubkey -noout -in jira_publickey.cer > jira_publickey.pem

This generates the files jira_privatekey.pcks8, jira_privatekey.pem, jira_publickey.cer and jira_publickey.pem.

Note that on Windows the > jira_publickey.pem last part of the command may not work, in which case you can just use openssl x509 -pubkey -noout -in jira_publickey.cer then copy the terminal output (including the -------BEGIN PUBLIC KEY-------- and -------END PUBLIC KEY-------- lines) and paste it into a file named jira_publickey.pem

Step 2: Configure the client app as a consumer in Jira

Log into your Jira instance and click Jira settings -> Products -> Application links from the sidebar menu:

jira-application-links

In the "Enter the URL of the application you want to link" field, enter any URL and then click on Create new link. Ignore any warning about "No response was received from the URL you entered - it may not be valid.", just click on Continue.

On the first screen of the Link applications pop-up window, The Consumer Key and shared secret are user defined. When setting up an application link on the Jira side, you specify what the consumer key and shared secret should be. Then, on the Tray side, you need to put these same values in so that Tray is able to authenticate to Jira. Be sure to select the Create incoming link checkbox.

jira-oauth

On the next screen of the Link applications popup window:

jira-link-applications

Enter the Consumer Key, Consumer Name and the Public key (copy the public key from the file jira_publickey.pem you generated previously). The Consumer Name is user defined, it's just for reference.

Then click on Continue.

You can now create a new authentication in the Tray workflow builder. You will use the following:

  • The Jira URL (without / at the end)
  • The Private key contained in the file jira_privatekey.pem
  • The consumer key specified in the second screen of the Link applications popup window
  • The shared secret specified in the first screen of the Link applications popup window

jira-add-auth

Username/Password Authentication

You can easily create a Username/Password authentication with Jira by using the 1.x version of the connector and specifying the username, password and your Jira URL (e.g. https://myjiradomain.atlassian.net).

jira-add-uname-pword

Basic Operations List

The available operations for the connector:

  • Create issue

  • Create issue comment

  • Delete issue

  • Get issue

  • Get user

  • List issue comments

  • List project issues

  • List projects

  • Update issue

Notes on operations usage

The Jira connector supports two authentication methods: Username/Password and OAuth1. The Username/Password authentication is the simplest way to authenticate to your Jira instance, however it is less secure than OAuth1. On the other hand, OAuth1 requires some additional steps which are explained in the above paragraphs.

If you want to use a Username/Password authentication, then use the connector version 1.x

If you want to use a OAuth1 authentication, then use the connector version 2.x

Using the Universal Operation ('Raw HTTP request')

As of version 2.3 it is now possible to effectively create your own operations.

This is a very powerful feature which you can put to use when there is an endpoint in Jira which is not used by any of our operations.

To use this you will first of all need to research the endpoint in the Jira API documentation, to find the exact format that Jira will be expecting the endpoint to be passed in.

Note that you will only need to add the suffix to the endpoint, as the base url will be automatically set (the base url is picked up from the value you entered when you created your authentication).

The base url is in the format of https://your-domain.atlassian.net/rest/api/2/

For example say that the Get issue operation did not exist in our Jira connector and you wanted to use this endpoint, you would use the Jira API docs to find that the get issue endpoint is a get request at the following url:

jira-get-issue-endpoint

So if you know that an issue key is 'DCP-165' you can get this issue with the following settings:

jira-get-issue-endpoint-props-panel

As another example, if you wanted to return the system and custom issue fields available in your Jira instance, the API docs tell you that this is a get request at the following endpoint:

jira-get-field-endpoint

So you can get this information just using the following setting:

jira-get-field-endpoint-props-panel

Note: If you are using DELETE you will have to set the content type to 'application/json' if body type is none (which it will be in most cases)

Example usage - setting up a JIRA bot in Slack

Here in the Tray.io docs department we have a JIRA bot set up to send Slack notifications about documentation which has been put on hold or is ready to be published. These serve as reminders to make sure that nothing 'slips through the cracks'.

This is managed with a very simple workflow:

jira-docs-bot-workflow

This workflow does the following:

  1. A scheduled trigger runs once a week
  2. Using JQL (Jira Query Language) a check is made for any docs tickets with a status of 'On Hold' or 'Ready to Publish'
  3. A loop connector goes through these tickets one-by-one
  4. The relevant 'docs-notifications' Slack channel is notified of each ticket

And the final output in Slack looks like this:

jira-docs-bot-slack-output

Step 1 - set the scheduled trigger

First the trigger is set to run at a certain time every week:

jira-bot-scheduled-trigger

Step 2 - set the query to filter tickets by project and status

Next we can use the Search Issues (JQL) operation to build a filter using the Jira Query Language (JQL) :

jira-filter-tickets

Step 3 - loop through the filtered tickets

Now we can use the loop connector and a $.steps.jira-1.issues jsonpath to pick up the results which match the query and loop through each of them one-by-one:

jira-loop-thru-tickets

Step 4 - compose the Slack message for each ticket

Finally we can use interpolated mode to compose the Slack message using the jsonpaths which extract the relevant ticket metadata from each ticket in the loop step:

jira-slack-step

You can see that the message box corresponds with the messages that are then output to Slack:

jira-docs-bot-slack-output

Note that for the Slack Send message operation you can set Username and Icon url:

jira-icon

Was this article helpful?
Yes
No