Setting up Slack notifications for build results with Jenkins is pretty simple. You’ll need the following:
- A Jenkins server that you have admin rights to.
- Slack Notification Plugin
- A Slack workspace, ideally with a channel dedicated to Jenkins alerts.
To set up Slack, go to .slack.com/apps and search for Jenkins CI:
Add the configuration and set the desired channel where alerts will appear.
After this, you’ll see some directions on setting up Slack on the Jenkins side.
When you’ve finished the setup, make sure to test the connection – you should see a message in Slack like the following:
Adding Jenkins Calls to Pipeline
Once the setup is complete, you can use the following examples to call Slack during the pipeline jobs:
This example will call a successful message when all stages complete, and sends a failure message if the build as a whole fails.