How To Automate Jira Ticket Transitioning And Comments?

Reading Time: < 1 minute

In this article, we will talk about how to automate Jira ticket transitioning and comments. Whether you have an existing Jira project workflow or you are creating one from scratch, you need to set up automation for basic things like transitioning the ticket, automated comments, auto-close, etc.

Your project workflow might have tools that go beyond Jira and having all those connected to Jira is something you might be interested in.

Of course, there are plugins that help you do it but what if you don’t want to do all that setup especially when it involves going back and forth between different teams. What if you wanted to handle it yourself?

How To Transition A Jira Ticket Using Jira REST API?

You can use the following cURL command:

curl -k -u $Juser:$Jpass -X POST --data '{"transition":{"id":<transition_id>}}' -H "Content-type: application/json" https://<jira_server>/rest/api/2/issue/$ISSUE/transitions?expand=transitions.fields

Replace your Jira server URL and transition ID.

Note: Jira has deprecated the basic auth. It means your $Jpass variable should not contain the plain password instead it should contain the token.

How To Generate A Personal Jira API Token?

  1. Click on your profile icon on the top right.
  2. Select Manage account.
  3. On the left panel, click Security.
  4. Under API token, click on Create or manage API tokens.
  5. Finally, click on the button that says Create API token.

How To Get The Jira Issue Transition ID?

There are 2 ways:

  1. Go to your project workflow, edit workflow in text mode and you will see transition IDs for transitions.
  2. The second way is to again use the Jira REST API:

How To Post Comment On A Jira Ticket Using Jira REST API?

curl -k -u $Juser:$Jpass -X POST --data '{"body": "Your comment here."}' -H "Content-type: application/json" https://<jira_server>/rest/api/2/issue/$ISSUE/comment

Written by 

Mohit Saxena is a Software Consultant having experience of more than 2 years. He is always up for new challenges and loves to aggressively move towards completing the software requirements. On a personal front, he loves to climb mountains and is a big foodie.