Jira Script Runner - Mail not sent by Post Create Transition

we have a project in Jira that we use as an email inbox. Not all people sending emails are JIRA users (and should not be). However, we would like to report receipt of email. The email address is part of the description of the problem.

I know some plugins there, but instead of replacing Mailhandlers, I am trying to write a groovy script for JIRA, adapting this code , which I want to send a message to the Post function when the CREATE transition of the workflow.

The following code works fine when I grab an existing test problem and run the script in the console:

import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.IssueManager import com.atlassian.mail.Email import com.atlassian.mail.server.MailServerManager import com.atlassian.mail.server.SMTPMailServer ComponentManager componentManager = ComponentManager.getInstance() MailServerManager mailServerManager = componentManager.getMailServerManager() SMTPMailServer mailServer = mailServerManager.getDefaultSMTPMailServer() if (mailServer) { if (true) { IssueManager issueManager = componentManager.getIssueManager() Issue issue = issueManager.getIssueObject("IN-376") def grabEmail = { (((it.split( "\\[Created via e-mail received from:")[1]).split("<")[1]).split(">")[0]) } String senderAddress = grabEmail("${issue.description}") Email email = new Email(senderAddress) email.setSubject("JIRA Ticket erstellt: ${issue.summary}") String content = "Content ----> by Issue2 ${issue.description}" email.setBody(content) mailServer.send(email) } } 

Alas, it will not start in the Post function, like this:

 import com.atlassian.jira.ComponentManager import com.atlassian.jira.issue.Issue //import com.atlassian.jira.issue.IssueManager import com.atlassian.mail.Email import com.atlassian.mail.server.MailServerManager import com.atlassian.mail.server.SMTPMailServer ComponentManager componentManager = ComponentManager.getInstance() MailServerManager mailServerManager = componentManager.getMailServerManager() SMTPMailServer mailServer = mailServerManager.getDefaultSMTPMailServer() if (mailServer) { if (true) { //IssueManager issueManager = componentManager.getIssueManager() //Issue issue = issueManager.getIssueObject("IN-376") def grabEmail = { (((it.split( "\\[Created via e-mail received from:")[1]).split("<")[1]).split(">")[0]) } String senderAddress = grabEmail("${issue.description}") Email email = new Email(senderAddress) email.setSubject("JIRA Ticket erstellt: ${issue.summary}") String content = "Content ----> by Issue2 ${issue.description}" email.setBody(content) mailServer.send(email) } } 

I have no idea why the second code breaks, since the code on which it is based uses the problem just as if it were implicitly defined. This Post function is the last to run.

I would also find tips on debugging this problem.

Thanks!

+7
scripting email groovy jira
source share
1 answer

I will post my comment as an answer: then I did not find an error in any of the logs. Perhaps I watched this, sorry, but now I changed a lot of settings (installing the JEMH test), so I can not play. Oddly enough, the message is being sent right now, so I have such a bad feeling that I have incorrectly configured the Notifications Scheme.

Thank you all for your help and time.

0
source share

All Articles