email - Jira Script Runner - 创建转换的 Post 功能不发送邮件

标签 email groovy scripting jira

我们在 Jira 中有一个项目,我们将其用作电子邮件收件箱。并非所有发送电子邮件的人都是 JIRA 的用户(他们也不应该是)。尽管如此,我们还是想在收到电子邮件后通知您。电子邮件地址是问题描述的一部分。

我知道有一些插件,但我不是替换邮件处理程序,而是尝试编写一个用于 JIRA 适应的常规脚本 this code我想将其发布到工作流程的 CREATE 转换上的后函数中。

当我抓取现有的测试问题并在控制台中运行脚本时,以下代码工作正常:

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)


    }
}

唉,它不会像这样在 Post 函数中运行:

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)


    }
}

我不知道为什么第二个代码会中断,因为它所基于的代码也使用了问题,就好像它是隐式定义的一样。此 Post 函数是最后运行的。

我还发现有关调试此问题的提示很有帮助。

谢谢!

最佳答案

我将发布我的评论作为答案:那么我在任何日志中都没有发现错误。也许是我监督了它,抱歉,但我现在已经更改了很多配置(安装 JEMH 试用版),所以我无法重现。奇怪的是,消息现在就发送了,所以我有一种不好的感觉,我在通知方案中的一些配置错误。

感谢大家的帮助和时间。

关于email - Jira Script Runner - 创建转换的 Post 功能不发送邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31297301/

相关文章:

dictionary - 为什么通过括号中的变量访问groovy map总是返回null?

shell - 删除重复行而不排序

php - 电子邮件——在电子邮件中换行的正确方法是什么?

c++ - 无法使用 Poco 库检索电子邮件内容

jquery - 如何通过ajax接收模型

variables - 使用 Powershell 替换 CSV 中的变量

python - 选择脚本语言

javascript - 有没有办法让电子邮件中的按钮远程发送数据?

node.js - 在Node.js中使用MongoDB中的电子邮件模板

java - Grails 服务无法使用 Optional 类