我正在尝试设置声明性管道故障的通知,如下所述:
https://jenkins.io/doc/pipeline/tour/post/
post {
failure {
emailext (
subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'",
body: """<p>FAILED: 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>""",
recipientProviders: [[$class: 'CulpritsRecipientProvider']]
)
}
}
}
如果构建中止,有没有办法不发送电子邮件?
在“旧”脚本管道中,我捕获了FlowInterruptedException来实现此目的。
catch (org.jenkinsci.plugins.workflow.steps.FlowInterruptedException e) {
echo "the job was cancelled or aborted"
currentBuild.result = 'ABORTED'
}
答案 0 :(得分:5)
https://issues.jenkins-ci.org/browse/JENKINS-43339已修复此问题 有一个错误将currentBuild.result设置为FAILURE而不是ABORTED。
确保在更新后重新启动jenkins。