我的Jenkins声明性管道具有以下后期处理措施:
mail to: '<snip>',
subject: "Status of pipeline: ${currentBuild.fullDisplayName}",
body: "${env.BUILD_URL} has result ${currentBuild.result}"
构建成功后,电子邮件正文的内容为:
<job name> has result null
我了解到作业成功时$ {currentBuild.result}“的值为null,但这对用户来说不方便。建议打印“ SUCCESS”(或“ FAILURE”等)的方式是什么?在正文消息中?
答案 0 :(得分:9)
改为使用${currentBuild.currentResult}
。
请参见https://qa.nuxeo.org/jenkins/pipeline-syntax/globals#currentBuild:
currentResult
通常为成功,不稳定或失败。永远不会为空。
答案 1 :(得分:2)
您可以在管道的发布步骤中添加邮件步骤,如下所示:
pipeline {
agent any
stages {
stage('Example Test') {
steps {
echo 'Hello, JDK'
}
}
}
post {
success {
echo "${env.BUILD_URL} has result success"
}
failure {
echo "${env.BUILD_URL} has result fail"
}
}
}