我想将现有的Jenkins管道转换为新的声明式管道,我想知道如何正确处理邮件通知?如何在Jenkins声明式管道中发送“恢复正常”通知?
我目前使用此代码:
node {
try {
...
currentBuild.result = 'SUCCESS'
} catch (any) {
currentBuild.result = 'FAILURE'
throw any
} finally {
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: "[email protected]",
sendToIndividuals: true])
}
}
它运作良好,但我不明白如何使用新的声明语法这一点。我认为可以通过使用post()和不同的通知来完成,但我不知道如何。我试过这个:
post {
always {
step([$class: 'Mailer',
notifyEveryUnstableBuild: true,
recipients: "[email protected]",
sendToIndividuals: true])
}
}
但问题是,它不会发送任何“回到正常”的邮件。
如何在Jenkins声明式管道中使用Mailer插件来发送“回到正常”邮件?
应该再次使用围绕所有声明语法的try/catch?