简体   繁体   English

如何在Jenkins管道中获取成功/失败构建信息?

[英]How to get the success/fail build information in a Jenkins pipeline?

I need to execute shell script if build is success and execute other script if it fails, is there any plugin or shell script to get build success/failure? 如果构建成功,我需要执行Shell脚本,如果构建失败,则需要执行其他脚本,是否有任何插件或Shell脚本来获取构建成功/失败? Thanks in advance 提前致谢

You can write a Groovy pipiline with this structure: 您可以使用以下结构编写Groovy pipiline:

node {
//Define your variables (if you need)

    stage('First stage') {
       try {
           //Your code
       } catch (Exception err) {
           currentBuild.result = 'FAILURE'
       }
    }

    stage('Last stage') {
         try {
           //Your code
        } catch (Exception err) {
           currentBuild.result = 'FAILURE'
        }
     }

     echo "RESULT: ${currentBuild.result}"
}

Second, thirty... stages only will be executed if previusly steeps builds correctly. 第二,只有在正确的陡坡建造正确的情况下,才会执行三十...阶段。

If all your stages build correctly, the status in Jenkins will be SUCCESS but if anyone fails the status will be FAILURE. 如果您的所有阶段都正确构建,则Jenkins中的状态将为SUCCESS,但是如果任何人失败,则状态将为FAILURE。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 jenkins 管道中编写 email 配置以发送不同的构建成功和构建失败信息集? - How to write email configuration in jenkins pipeline to send different set of information for build success and build failure? 詹金斯管道失败,但目前的结果是成功 - Jenkins pipeline fail but current result is success 如何操纵 Jenkins 管道作业的构建结果(回到“成功”)? - How to manipulate the build result of a Jenkins pipeline job (back to 'SUCCESS')? 如何在 jenkins 经典 ui 管道的脚本步骤中获取上游构建信息 - how to get upstream build information in a script step of jenkins classic ui pipeline 如何在测试失败时停止 jenkins 管道构建 - 并将其标记为不稳定 - How to stop a jenkins pipeline build when tests fail - and mark it unstable 在脚本化管道中,如何获取Jenkins构建参数 - In scripted pipeline, how to get Jenkins build parameters 如何获取Jenkins插件Build User Vars以与Jenkins Pipeline一起使用 - How to get the Jenkins plugin Build User Vars to work with Jenkins Pipeline 获取 Jenkins 流水线构建步骤 - Get Jenkins Pipeline Build steps Jenkins管道:无法在构建控制台中找到基于字符串的构建 - Jenkins pipeline: fail build on string found in build console 标记 Jenkins 构建成功,以防输入超时? (声明式管道) - Mark Jenkins build as success, in case of timeout on input? (declarative pipeline)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM