gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 13:32:29 25 4
gpt4 key购买 nike

我们在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com