我如何在下面的声明性管道中获得构建状态

时间:2019-06-19 11:16:17

标签: jenkins-pipeline jenkins-groovy

script{
    build job : 'somejob', 
    parameters: [
        extendedChoice(name: 'some_choice', value: "${env.some_choice}")
    ], 
    propagate: false  
} 
echo  "${currentBuild.Currentresult} 

如何在上述说明性管道中获取构建作业的状态 ${currentBuild.Currentresult}总是返回成功

1 个答案:

答案 0 :(得分:0)

只需将其作为currentBuild访问。例如,在我的代码中,我将buildStatus传递给如下所示的库:

stage('notify') {
            steps {
                script {
                    echo "end!!"
                    slackHelper.finalBuildStatusMessage(currentBuild)
                    slackSend(channel: '#ci-cd', attachments: slackHelper.getFinalSlackMessage())
                }
            }
        }