Closed fency12 closed 1 year ago
stages {
stage('测试成功失败') {
steps {
sh 'echo 不能失败啊'
}
}
stage('发送飞书消息') {
steps {
FeiShu(webhook:'https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxc8',proxy:'',msg:'',type:'',atAll:false)
// 下面失败和成功上面都会通知
}
}
}
如果使用声明式语法,请在stages代码块后面添加post后置块显式指定捕获错误,例如
post { failure { FeiShu(webhook:'',proxy:'',message:'',atAll:false) } }
如果想要获取流水线某个阶段的构建状态,应该用warn(需要jenkins版本较新)或catchError块包起来,例如
catchError(message:'xxx',buildResult:'failure',stageResult:'unstable') { FeiShu(webhook:'',proxy:'',message:'',atAll:false) }
好的已解决。谢谢大佬
pipline脚本式如下: stages { stage('测试成功失败') { steps { sh 'echo 不能失败啊' } } stage('发送飞书消息') { steps { FeiShu(webhook:'https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxx8',proxy:'',msg:'',type:'',atAll:false) // 下面失败和成功上面都会通知 } } }
执行结果如下图:
问题: 1、pipline通知到jenkins如法获取构建状态? 2、如果上面的stage内的steps构建失败,下面的通知并不会执行,这个如何解决?