I want to use the Slack Notification Plugin in my pipelines, which is very easy:
slackSend color: 'danger', message: 'Everything broke'
However, I don't want the build to break if slackSend doesn't exist. Is there a way to check that first?
From the Jenkins home page: Click Manage Jenkins. Click Manage Plugins. Click on the Installed tab.
The Easiest Way to Get a Plugin For Jenkins Select Manage Jenkins > Manage Plugins. Here you should see a tab called Advanced, where there will be an option to upload the plugin. Most plugins can be installed immediately by clicking Install without restart.
Within a Pipeline Project (read plugin), Jenkins introduces a domain-specific language (DSL) based on 'Groovy', which can be used to define a new pipeline as a script. The flow that would typically require many “standard” Jenkins jobs chained together, can be expressed as a single script.
Pipelines are Jenkins jobs enabled by the Pipeline (formerly called “workflow”) plugin and built with simple text scripts that use a Pipeline DSL (domain-specific language) based on the Groovy programming language.
You might be able to wrap it in a conditional, though I'm not sure how Jenkins adds stuff to the scripts...
if(this.respondsTo('slackSend')) {
slackSend color: 'danger', message: 'Everything broke'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With