[英]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.