Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Email Jira脚本运行程序-邮件不是通过创建转换的Post函数发送的_Email_Groovy_Scripting_Jira - Fatal编程技术网

Email Jira脚本运行程序-邮件不是通过创建转换的Post函数发送的

Email Jira脚本运行程序-邮件不是通过创建转换的Post函数发送的,email,groovy,scripting,jira,Email,Groovy,Scripting,Jira,我们在Jira有一个项目,我们用它作为电子邮件的收件箱。并非所有发送电子邮件的人都是JIRA的用户(他们也不应该是)。尽管如此,我们希望在收到电子邮件后通知您。电子邮件地址是问题描述的一部分 我知道有一些插件,但我没有替换MailHandler,而是尝试为JIRA编写一个groovy脚本,我想将其发布到工作流创建转换的post函数中 当我获取现有测试问题并在控制台中运行脚本时,以下代码工作正常: import com.atlassian.jira.ComponentManager import

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

我知道有一些插件,但我没有替换MailHandler,而是尝试为JIRA编写一个groovy脚本,我想将其发布到工作流创建转换的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)


    }
}
import com.atlassian.jira.ComponentManager
导入com.atlassian.jira.issue.issue
导入com.atlassian.jira.issue.IssueManager
导入com.atlassian.mail.Email
导入com.atlassian.mail.server.MailServerManager
导入com.atlassian.mail.server.SMTPMailServer
ComponentManager ComponentManager=ComponentManager.getInstance()
MailServerManager MailServerManager=componentManager.getMailServerManager()
SMTPMailServer mailServer=mailServerManager.getDefaultSMTPMailServer()
如果(邮件服务器){
如果(真){
IssueManager IssueManager=componentManager.getIssueManager()
Issue=issueManager.getIssueObject(“IN-376”)
def抓取电子邮件={
(((it.split(“\\[通过从以下地址收到的电子邮件创建”)[1]).split(“”[0])
}
字符串senderAddress=grabEmail(${issue.description})
电子邮件=新电子邮件(发件人地址)
email.setSubject(“JIRA-Ticket-erstellt:${issue.summary}”)
String content=“content-->by Issue2${issue.description}”
email.setBody(内容)
mailServer.send(电子邮件)
}
}
唉,它不会像这样在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)


    }
}
import com.atlassian.jira.ComponentManager
导入com.atlassian.jira.issue.issue
//导入com.atlassian.jira.issue.IssueManager
导入com.atlassian.mail.Email
导入com.atlassian.mail.server.MailServerManager
导入com.atlassian.mail.server.SMTPMailServer
ComponentManager ComponentManager=ComponentManager.getInstance()
MailServerManager MailServerManager=componentManager.getMailServerManager()
SMTPMailServer mailServer=mailServerManager.getDefaultSMTPMailServer()
如果(邮件服务器){
如果(真){
//IssueManager IssueManager=componentManager.getIssueManager()
//Issue=issueManager.getIssueObject(“IN-376”)
def抓取电子邮件={
(((it.split(“\\[通过从以下地址收到的电子邮件创建”)[1]).split(“”[0])
}
字符串senderAddress=grabEmail(${issue.description})
电子邮件=新电子邮件(发件人地址)
email.setSubject(“JIRA-Ticket-erstellt:${issue.summary}”)
String content=“content-->by Issue2${issue.description}”
email.setBody(内容)
mailServer.send(电子邮件)
}
}
我不知道为什么第二个代码会中断,因为它所基于的代码使用了这个问题,就好像它是隐式定义的一样。这个Post函数是最后一个运行的

我还发现调试这个问题的提示很有帮助


谢谢!

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


感谢大家的帮助和时间。

如何调试?我曾经使用此问题来输出调试消息。将您的代码放入try-catch块中,并将异常发送到问题的描述中。这对其他类型的调试消息也适用……您启用了发送邮件功能吗?@user880772:第二行是com门蒂out@Nuwan:是的,并且第一个代码确实发送邮件。那么,我在任何日志中都没有发现错误。可能是我监督了它,对不起,但是我现在已经更改了很多配置(安装JEMH试用版)所以我无法复制。奇怪的是,消息现在就被发送了,所以我有一种不好的感觉,我在通知方案中的一些配置错误。