Overview
Please note: this solution was originally posted by Peter-Dave Sheehan on the Atlassian Forums. I’m just explaining how I use it.
Sometimes when I’m trying to solve a problem with Jira, the internal Java libraries just aren’t sufficient. They’re often not documented, or they’re opaque.
It’s often far easier to turn to the REST API to get work done, but that’s a little more tricky on Jira DC or Server than it is on Cloud. On Jira Cloud, a REST call could be as simple as:
def result = get("/rest/api/2/issue/<issue key>")
.header('Content-Type', 'application/json')
.asObject(Map)
result.body.fields.comment.comments.body.each{field->
return field
}
}
However this won’t work on Server/DC. Instead we need a REST framework upon which to build our script.
The Framework
This piece of code uses the currently logged in user to authenticate against the Jira REST API. It then makes a GET call to the designated API endpoint URL.
The script returns a JSON blob. With point notation, we can then easily access its individual attributes, and