Dav*_*idA 5 jenkins jenkins-declarative-pipeline
我的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”等)的建议方式是什么信息?
PKo*_*PKo 17
使用${currentBuild.currentResult}代替。
参见https://qa.nuxeo.org/jenkins/pipeline-syntax/globals#currentBuild:
currentResult
通常是成功,不稳定或失败。永远不会为空。
另请参阅https://issues.jenkins.io/browse/WEBSITE-364
小智 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"
      }
     }
 }
| 归档时间: | 
 | 
| 查看次数: | 15652 次 | 
| 最近记录: |