Pages

Tuesday, May 7, 2019

Jenkins - Integration with Slack

Notifications are very important in a Continuous Integration System. The most basic notification type is the email. A Build job sends a notification as an email when it fails or completes successfully. Now a days people requires these notifications not just by emails but by sending sms or messages to their chat channels etc.

Slack is essentially a chat room for the whole company designed to replace email as your primary method of communication and sharing. Slack has a concept of Workspaces which allow one to organize communication by channels for group discussions, private messaging to share information and more 

One of the best feature of slack is it integrates with different tools by which it allows to send notifications to the channels. In this article we will see how we can send a build notification to the slack channel from the Jenkins Server

Create a free account with the slack. This lets you create a workspace for your collaboration. Once you are logged in to the workspace, choose the Apps below which allows you to install apps.

Once you click on the apps, it will allows you to browse for the apps. Search for jenkins and choose install. We have to create a channel so that the notifications come over there. I created a channel by the name “jenkins-channel”

Once you choose install, it will take you to a page which gives Base URL and Integration key details like below,
Base URL: https:///services/hooks/jenkins-ci/
Integration Token: ******************

On the Jenkins Side
:
Go to Manage Jenkins -> Manage Plugins, Install the Slack Notification plugin from the Available tab. Make sure your version is 2.2. Install the plugin

Go to Manage Jenkins -> Configure System -> Find “Global Slack Notifier Settings” and fill the values.Fill the app URL as provided by the Slack.
Create a Secret Text token credentials with a name and in the secret text , enter the Integration token provided by slack and Save it

Choose the credential created above in the “integration token credential ID” field. Test the connection and check if that is success.

On the Jenkins Job Side :
Choose the “slack Notifications” on the Post Build actions and choose the checkbox that you would like to see messages from. I have chosen all and run the job.


Once the job is ran successfully in this case, we can see a notification message coming from slack to the workspace in slack. Go to the Slack workspace and in the jenkins-channel , we can see notifications like below,

No comments :

Post a Comment