I started using Script Runner (specifically Send a custom email) to work around the poor email notifications in JIRA Service Desk. So far it has worked well. The only struggle I have is with notifying users when comments are added. In Service Desk, there are internal and external comments. I want to be able to send a custom email to the reporter only when an external comment is added and include the text of that comment.
I've struggled with this a bit, but here's what I've found:
I can query the API for a particular comment ID and get the JSON property
In the Script Runner console, I can get a true/false value on whether a comment is internal or not:
def curl = "/usr/bin/curl -u admin:admin https://jira/rest/api/2/comment/12171/properties/sd.public.comment/" def result = curl.execute().text output = result.contains("true")
I can use the code above in a condition and it evaluates correctly, but the comment ID is hard coded. I tried this:
import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.comments.CommentManager def id = ComponentManager.getCommentManager().getComments(issue).last().id
to get the comment ID, but I keep getting an error:
No signature of method: static com.atlassian.jira.ComponentManager.getCommentManager() is applicable for argument types: () values:  Possible solutions: getCommentManager(), getConstantsManager(), getProjectManager(), getVoteManager()
How can I get the comment ID in the "Condition" field of Send a custom email?
I really advise you not to use this approach... although kudos for finding it. The problem is that for anyone that uses SSL they are likely to have certificate problems, plus you are hard-coding credentials, and it's not easy to use the credentials of some other user. A better approach (imho) is here: https://answers.atlassian.com/questions/14212548/answers/14212563
Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs