gpt4 book ai didi

jenkins - ext-email 插件,不从管道向默认收件人发送电子邮件

转载 作者:行者123 更新时间:2023-12-02 17:05:19 24 4
gpt4 key购买 nike

我正在尝试借助 ext-email 插件从 Jenkins 脚本管道发送电子邮件。

我已经为插件配置了默认收件人。

这是我的管道:

node {
try {
echo "hi"
} catch (e) {
currentBuild.result = "FAILED"
notifyBuild(currentBuild.result)
throw e
}
finally {
notifyBuild(currentBuild.result)
}
}

def notifyBuild(String buildStatus = 'STARTED') {
buildStatus = buildStatus ?: 'SUCCESSFUL'
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
def summary = "${subject} (${env.BUILD_URL})"
def details = """
<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at "<a href="${env.BUILD_URL}">${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>
"""
emailext (
subject: subject,
body: details,
attachLog: true,
to: ${DEFAULT_RECIPIENTS},
recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider'], [$class: 'CulpritsRecipientProvider']]
)
}

我试图将电子邮件发送给触发作业的用户,但我没有收到发送给 DEFAULT_RECIPIENTS 的电子邮件。我还尝试使用 to: env.DEFAULT_RECIPIENTS

我收到这个错误:

groovy.lang.MissingPropertyException: No such property: $DEFAULT_RECIPIENTS for class: groovy.lang.Binding

最佳答案

我也遇到了同样的问题,刚才我通过以下步骤找到了解决方案:

emailext body: '''${SCRIPT, template="groovy-html.template"}''', 
subject: "${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - Successful",
mimeType: 'text/html',to: '$DEFAULT_RECIPIENTS'

记下 $DEFAULT_RECIPIENTS 周围的单引号,这是此处成功的关键。

我不知道为什么不使用双引号:(

关于jenkins - ext-email 插件,不从管道向默认收件人发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52039059/

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