检查Jenkins管道内存在的插件(Groovy) [英] Check a plugin exists within a Jenkins Pipeline (Groovy)
本文介绍了检查Jenkins管道内存在的插件(Groovy)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的管道中使用Slack Notification Plugin,这非常简单:
I want to use the Slack Notification Plugin in my pipelines, which is very easy:
slackSend color: 'danger', message: 'Everything broke'
但是,如果slackSend不会让构建中断不存在。有没有办法首先检查?
However, I don't want the build to break if slackSend doesn't exist. Is there a way to check that first?
推荐答案
你总是可以使用旧的try / catch来确保你的构建不会'
You could always use the old try/catch to make sure your build doesn't fail on this step :
def resultBefore = currentBuild.result
try {
slackSend color: 'danger', message: 'Everything broke'
} catch(err) {
currentBuild.result = resultBefore
}
但是,我真的不明白为什么 slackSend
命令不存在?它可能会失败(例如,如果您的Slack服务器关闭),但只要您安装了 Slack Notification Plugin
,它应该存在!
However, I don't really see why slackSend
command would not exist ? It can fail (e.g. if your Slack server is down) but as long as you have Slack Notification Plugin
installed it should exist !
这篇关于检查Jenkins管道内存在的插件(Groovy)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文