JIRA API Token with Groovy

This is about how to access JIRA with API token using Groovy

How to create JIRA API Token

To create an API token please go to your Atlassian account and create a new API token.

Go here for more details ->

Access JIRA Ids Using tokens

To access an issue we need to call the /rest/api/3/issue/{issueIdOrKey} endpoint on your Jira Cloud instance. This returns the details for an issue.

The issue is identified by its ID or key, however, if the identifier doesn’t match an issue, a case-insensitive search and check for moved issues is performed. If a matching issue is found its details are returned, a 302 or other redirect is not returned. The issue key returned in the response is the key of the issue found.

In the above example logn@user.com is Jira login and the API token is sTJDYqaz2wsx7. And the if is the JIRA card number

Create JIRA

Creates an issue or, where the option to create subtasks is enabled in Jira, a subtask. A transition may be applied, to move the issue or subtask to a workflow step other than the default start step, and issue properties set.

More details

Most important part is create the content, it can be a Story, Task or a Bug, What kind of priorities like low, medium, and many more information you need when creating a JIRA. Sample content is showing below

Project key can easily find when contacted JIRA administrator or from getJiraByID in previous example

Above json content can be loaded like

If needed you can process dynamically before creating the JIRA

Finally create Jira

Now there are many more things you can do on JIRA using Groovy

Please play around using API documentation

Share with me if you find something interesting :)

Technology Evangelist, Technical Blogger with multidisciplinary skills with experience in full spectrum of design, architecture and development