Hello Community,
I am currently writing a script for using the script mail handler for achieving the following use case.
As per what I have read in the documentations, it is possible to do so using the script mail handler in the incoming mail handler settings.
In the document it shows how to get the commits from 3rd party app like bitbucket etc.
But in my case it will be coming from email. Also, I am not sure how to set the comment author since the actual author will be a non jira user.
I managed to write the following code it does seem to be working. So far it does not give any errors.
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.service.util.ServiceUtils
import com.atlassian.mail.MailUtils
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.service.util.handler.MessageUserProcessor
CommentManager commentManager = ComponentAccessor.getCommentManager()
def messageUserProcessor = ComponentAccessor.getComponent(MessageUserProcessor)
def subject = message.getSubject() as String
def issue = ServiceUtils.findIssueObjectInString(subject)
def body = MailUtils.getBody(message)
def sender = messageUserProcessor.getAuthorFromSender(message) as String
if (issue) {
def comment = sender + subject + " - " + body
commentManager.create(issue, reporter, comment, false)
}
If anyone has worked in this before? It would be a big help.
Thanks in advance,
Pooja
You can get external reporter identity using following code:
// get email sender
def reporterEmail = ""
final List<String> senders = MailUtils.getSenders(message);
for (final String emailAddress : senders)
{
reporterEmail = emailAddress
}
However, use default user to create issues for non jira users. That will help to reduce number of licenses.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.