As part our ChatOps configuration at work I am playing around with configuring different apps into our slack channel. In this post i will show you how to connect Jenkins into Slack for notifications.

Solution

Slack Configuration

From the channel you wish to send your notifications to press the Channel Settings button  (cog on the top right of the window) and select “Add an app or integration”

octslack04

In the search window Type “Jenkins CI” (With Jenkins we dont need to manually configure a webhook there is a pre-made app which does all the work for us)! Press “Install”

jenkinsslack06

We again put ion the Channel we want to send notifications and select “Add Jenkins CI integration”

jenkinsslack07

you will now get a page showing the Domain (This is simply the name of the Slack Community and a webhook URL) followed by some steps on how to configure the Jenkins side. COPY THE WEBHOOK URL and move over to Jenkins.

jenkinsslack08

Jenkins Configuration

From Jenkins Select: Manage Jenkins -> Manage Plugins:

Select Available Plugins

and search for : “Slack”

jenkinsslack

 

Select Slack Notification Plugin. Download and install without restart

jenkinsslack02

Now open Manage Jenkins -> Configure System  and scroll to the bottom of the page till you find the Globel Slack Notifier Settings. and insert you Integration Token, Slack Community name in Team Subdomain and channel

jenkinsslack10

Now you can go to any of your Jenkins Builds and a Post-build Step for “Slack Notification”

jenkinsslack11

Now you can choose when to send a notification based on Start, Failure, Sucess etc.

 

jenkinsslack09

Result

Now when you run the build you should see the below in your slack channel!

(For my test i created a job called “Test Slack” and selected notify options above)

jenkinsslack14

 

 

Advertisements