Hello, my goal is to get all possible information about the current issue and send it by e-mail.
The only thing I came up with is getting it from REST (similar to the way it is done when calling webhook in the post function)
The code below gives me a json wich I can email.
But I dont like to store a user credentials in a script. Can I somehow execute that REST call with a currently logged in user? The way it is done when calling a webhook (I mean that when I call a webhook in a postfunction it done with a current user credentials).
def user = "user"
def password = "passwd"
def urlConnection = new URL("http://jiratest.dom.com/rest/api/2/issue/ISS-56905").openConnection()
urlConnection.setRequestProperty("Authorization", "Basic " + (user + ":" + password).bytes.encodeBase64().toString())
def jsonString = IOUtils.toString(urlConnection.inputStream)
There might be a way, but I don't know it.
But you could get all the information from a jira issue using the JAVA api.
You could start with something like this and refine the output as needed (for example, expand user type fields).
def cfm = ComponentAccessor.customFieldManager
def im = ComponentAccessor.issueManager
def issue = im.getIssueObject('JSP-1922')
def issueMap = [key:issue.key, id:issue.id, fields:]
issueMap.fields << [summary: issue.summary]
issueMap.fields << [description: issue.description]
issueMap.fields << [assignee: issue.assignee]
issueMap.fields << [reporter: issue.reporter]
issueMap.fields << [(it.name) : issue.getCustomFieldValue(it)]
Thank you for your help. Your suggestion will do the trick, and I think I'll stick to it for now because it's the best solution for now.
The only thing there is a little mistype at "def issueMap" "fields" should be a LinkedHashMap instead of ArrayList. :)
def issueMap = [key:issue.key, id:issue.id, fields:[:]]
Thank you :)
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event