
When our teams are responsible for DevOps practices, we often need to monitor builds and other automated jobs.
In this tutorial, we’ll see how to configure two popular platforms, Jenkins and Slack, to work together and tell us what’s happening while our CI/CD pipelines are running.
Let’s start by configuring Slack so Jenkins can send messages to it. To do this, we’ll create a custom Slack app, which requires an Administrator account.
In Slack, we’ll create an application and generate an OAuth token:
When this is done, we’ll see a summary screen:
Now, we need to take note of the OAuth token — we’ll need it later when we configure Jenkins. We should treat these as sensitive credentials and keep them safe.
To complete the Slack setup, we must invite the new Jenkins user into the channels we wish it to use. One easy way to do this is to mention the new user with the @ character inside each channel.
To set up Jenkins, we’ll need an administrator account.
First, let’s start by logging into Jenkins and navigating to Manage Jenkins > Plugin Manager.
Then, on the Available tab, we’ll search for Slack:
Let’s select the checkbox for Slack Notification and click Install without restart.
Now, we need to configure new credentials. Let’s navigate to Jenkins > Credentials > System > Global Credentials and add a new Secret text credential:
We’ll put the OAuth token from Slack into the Secret field. We should also give these credentials a meaningful ID and description to help us easily identify them later. The Jenkins credentials store is a safe place to keep this token.
Once we save the credentials, there is one more global configuration to set. Under Jenkins > Manage Jenkins > Configure System, we need to check the Custom slack app bot user checkbox under the Slack section:
Now that we’ve completed the Jenkins setup, let’s look at how to configure Jenkins jobs and pipelines to send Slack messages.


Traditional Jenkins jobs usually execute one or more actions to accomplish their goals. These are configured via the Jenkins user interface.
In order to integrate a traditional job with Slack, we’ll use a post-build action.
Let’s pick any job, or create a new one. When we drop down the Add post-build action menu, we’ll find Slack Notifications:
Once selected, there are lots of available inputs to the Slack Notification action. Generally, most of the default values are sufficient. However, there are a few required pieces of information:
We can also specify additional fields if desired, such as commit information used for the Jenkins job, custom messages, custom bot icons, and more:
When setting things up via the UI, we can use the Test Connection button to ensure that Jenkins can reach Slack. If successful, we’ll see a test message in the Slack channel from the Jenkins user:
If the message doesn’t show up, the Jenkins log files are useful for troubleshooting. Generally, we need to double-check that the post-build action has all required fields, that the OAuth token was copied correctly, and that the token was granted the proper scopes when we configured Slack.

Jenkins Pipelines differ from traditional jobs. They use a single Groovy script, broken into stages, to define a build. They also don’t have post-build actions, so we use the pipeline script itself to send Slack messages
The following snippet sends a message to Slack from a Jenkins pipeline:
groovyslackSend botUser: true,channel: 'builds',color: '#00ff00',message: 'Testing Jekins with Slack',tokenCredentialId: 'slack-token'
Just like with the traditional Jenkins job setup, we must still specify a channel name and the name of the credential to use.
Via a Jenkins pipeline, we can also use a variety of additional Slack features, such as file upload, message threads, and more.
One downside to using Jenkins pipelines is that there’s no test button. To test the integration with Slack, we have to execute the whole pipeline.
When first setting things up, we can create a new pipeline that contains only the Slack command while we’re getting things working.


In this article, we’ve seen how to integrate Jenkins and Slack to gain feedback on our CI/CD pipelines.
Using a Jenkins plugin, along with a custom Slack application, we were able to send messages from Jenkins to Slack. This allows teams to notice the status of Jenkins jobs and address issues more quickly.

Hey there! Ever heard of Next.js? It's a pretty cool tool for creating single page web apps (SPA) and static web apps (SSG). Built on React, Next.js is packed with handy features that can shave hours off your development time and make your pages load lightning fast. In this piece, we're gonna check out what's new and exciting in the latest version of Next.js. Stay tuned!
Beiryu
Contributor

The Friend feature facilitates the management of user relationships, enabling connections and providing options for blocking interactions when necessary. This functionality enhances player connectivity and serves as a foundation for additional features, such as activity tracking and social engagement opportunities.
Beiryu
Contributor