Learn to integrate the Slack Notification plugin with Jenkins for automatic build status messages in Slack channels.
In this lesson, you’ll learn how to integrate the Slack Notification plugin with Jenkins to automatically publish build status messages to your Slack channels. This guide provides a step-by-step approach, complete with configuration details and example code blocks to help you set up and test notifications effectively.
Begin by installing the Slack Notification plugin on your Jenkins instance. This plugin is accessible via the Plugin Manager in Jenkins, helping to integrate Jenkins with Slack by sending build status messages.
After locating the plugin using the search feature, proceed with its installation. You can monitor the plugin download progress during the installation process:
Once the installation is complete, restart Jenkins to apply the new settings.
Before diving into configuration, it is essential to review the Slack Notification plugin documentation. If you are new to Slack, first create an account and set up your workspace. Within this workspace, create a dedicated Slack channel for receiving Jenkins notifications. For instance, you might create a channel named “Dasher notifications.”
Next, create a new Slack App in your workspace. In Slack’s app configuration, choose to create an app from an app manifest. Select your workspace (for our purposes, the Jenkins workspace), and replace any pre-filled content with the YAML manifest provided below.
After pasting the manifest into Slack’s configuration, click Next. You will see a summary page displaying the eight permissions associated with your bot user.
When you are satisfied with the configuration details, click Create. Once the app creation process is complete, Slack will provide you with an OAuth token. Be sure to click Install App to Workspace when prompted to ensure the app is properly installed in your Slack workspace.At times, you might encounter an alternative version of the manifest used internally by Slack, such as:
With your OAuth token ready, proceed to configure the Slack integration within Jenkins:
Navigate to Manage Jenkins → Configure System.
Locate the Slack notification settings.
Enter your workspace name (for example, Jenkins).
Create new credentials of type Secret Text, then paste your bot user OAuth token. For instance, set the credential ID as “Slack bot token.”
After adding the credentials, select the newly created Slack token in your configuration settings. Specify the Slack channel where notifications should be sent (e.g., “Dasher notifications”). For advanced settings, you may leave the default values for icon emoji and username.Click Test Connection. If you receive an error message like:
Copy
Ask AI
Failure(["ok":false,"error":"not_in_channel"])
This error indicates that your Jenkins app user is not a member of the specified Slack channel. To resolve this, invite the Jenkins app to the channel by typing @Jenkins (or the app’s display name) within the channel.
Once the app is added to the channel, test the connection again until you receive a success confirmation.To further verify the connection via a pipeline step, use the following command:
Copy
Ask AI
slackSend color: "good", message: "Message from Jenkins Pipeline"
This confirms that the integration is working correctly.
With these steps completed, you have successfully set up Slack notifications in Jenkins. Your build statuses and messages will now be automatically posted to the designated Slack channel, ensuring that you stay informed of build outcomes in real time.For further details about the Slack/Jenkins integration, you can visit the plugin page at Jenkins Plugin Page.Thank you for following this lesson.
For more information, consider reviewing the following resources: