詹金斯管道失败,但目前的结果是成功

时间:2019-07-11 10:26:10

标签: jenkins jenkins-pipeline

我已经安装了管道声明版本1.3.9,并且集成了slack插件以在管道完成时发送结果。 如果我在jenkins上看到,我可以看到构建失败,但是我收到的消息是成功。

这是我用来在松弛状态下发布的管道代码段

def COLOR_MAP = ['SUCCESS': 'good', 'FAILURE': 'danger', 'UNSTABLE': 'danger', 'ABORTED': 'danger']

slackSend channel: '#jenkins',
                            color: COLOR_MAP[currentBuild.currentResult],
                            message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}"

我该怎么做才能解决问题?

编辑:

post {
        failure {
            slackSend channel: '#jenkins',
                                color: 'danger',
                                message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} - Env ${params.deployEnvironment} \n More info at: ${env.BUILD_URL}"
        }
        success {
            slackSend channel: '#jenkins',
                                    color: COLOR_MAP[currentBuild.currentResult],
                                    message: "*${currentBuild.currentResult}:* Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} \n More info at: ${env.BUILD_URL}"
        }
    }

即使我这样做,在失败的情况下我也会有两个松弛通知

1 个答案:

答案 0 :(得分:0)

您可以使用 $users = User::with('tableA','tableB','tableC') ->whereHas('tableA') ->whereHas('tableB') ->whereHas('tableC') ->get(); 代替currentBuild.result

currentBuild.currentResult
相关问题