/** This example script listner script must bve configured to fire on the 'Issue Updated' Event and shows how to get all comments on the issue and then to get the last comment and to save the text from it to a varible. * "All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner* license shall be granted a non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed or* amended and must be included in any circumstances where the code snippet is shared by You or a third party." */// Get the key of the current issuedefissueKey=issue.key// Make a call to the Get Comments API to get all the comments on the issuedefgetComments=get("/rest/api/3/issue/${issueKey}/comment").header('Content-Type','application/json').asObject(Map)// If the issue has comments if(getComments.body.total!=0){// Save the last comment to a variable called lastCommentdeflastComment=getComments.body.comments.last().body.content.content.text.toString().replaceAll("\\[","").replaceAll("\\]","")// log out the last commentlogger.info("The Last Comment = "+lastComment)}else{// If the issue has no comments log out message to say this. logger.info("The issue has no comments")}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.