Documentation

The Slack plugin allows for configuring a default Slack channel, or a Slack channel may be defined on a per build task basis. There are several things that need to be done to get the Slack plugin working. The projects home page is on Github.

Global configuration

Configure the "Jenkins", "Manage Jenkins", "Configure System", "Global Slack Notifier Settings" values. Scroll to the bottom of the screen or search for the word "Slack" to find the entry.

Enter the Team domain, Integration Token, and Build Server URL into the indicated text fields.

If you have a default channel name (e.g. #builds) enter this name into the "Channel" text field.

If you have entered a default channel name, click the "Test Connection" button.

Project Configuration

Select the check boxes for the notifications desired when the build task is executed.

If the project has a different channel from the default perform the following steps.

Click on the "Advanced..." button.

Enter the "Team Domain", "Integration Token" (probably the same as the Global token), and "Project Channel" name in the indicated text fields. Do not rely on the defaults to populate any of the fields. Enter the information even if it is redundant with the Global configuration.

Click on the "Test Connection" button.

Verify a test message was sent to the appropriate Slack channel.

Click on the "Save" button to retain these changes.

Post-build Actions

If you forget this section, the test buttons will show the channel test messages, but the build execution will not post anything to the channel.

Scroll to the "Post-build Actions" section of the project configuration.

Click on the "Add post-build action" button.

Select the "Slack Notifications" entry from the list displayed. The "Slack Notifications" section will appear in the window.

42 Comments

I have set up the integration with Jenkins and tested connection from Configure System@Jenkins and it worked OK. Than I added Slack notification post build action for some job and executed it. When the job is completed, I do not get any notification on my Slack channel. Anyone with the same issue?

The plugin works well and shows notification in slack upon build failure for first time but for the second time build failure i don't get any notifications. I don't see any option Notify Repeated Failure either. Please help I am using v1.8.1 which is the latest version.

java.lang.NullPointerException
at java.util.TreeMap.put(TreeMap.java:568)
at java.util.TreeSet.add(TreeSet.java:267)
at jenkins.model.Jenkins.getUnprotectedRootActions(Jenkins.java:3916)
at jenkins.model.Jenkins.getTarget(Jenkins.java:3885)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:674)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876)
at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649)
at org.kohsuke.stapler.Stapler.service(Stapler.java:238)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:686)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1494)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:132)
at hudson.plugins.greenballs.GreenBallFilter.doFilter(GreenBallFilter.java:59)
at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:129)
at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:123)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1482)
at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:49)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1482)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84)
at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:135)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249)
at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67)
at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87)
at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76)
at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1482)
at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1482)
at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:81)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1482)
at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1474)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:533)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
at org.eclipse.jetty.server.AbstractHttpConnection.headerComplete(AbstractHttpConnection.java:949)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.headerComplete(AbstractHttpConnection.java:1011)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:644)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:235)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1157)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:627)
at java.lang.Thread.run(Thread.java:863)

Thanks for providing an example on using this plugin with Pipelines. It would be even better if you could extend it a little bit to tag the person that triggered the build or all the committers. Now the "Slack message" body is not really useful.

Hello, I have slack plugin configured in Jenkins 1.651.3 and it publishes build status such as `Smoke-Tests - #1234 Unstable after 4 min 53 sec (Open)` but I would like for it to also publish detailed counts such as `Test Status: Passed: 76, Failed: 0, Skipped: 0`. I am using TestNG and the job's "Publish JUnit test result report" is configured as "**/test-output/junitreports/*.xml". My understanding is that when publishing JUnit test result report, the Slack plugin should automatically publish the test result count, but this is not happening.

You need a separate job just for sending notifications that accepts a single string parameter for the success message. It will then use the parameter as a customised message in the slack plugin.

Then on the matrix project, Add a post-build action to "Trigger parameterized build on other projects" to pass a success message to that separate job. This works as it only gets build after all matrix configurations are built.

Option 1. If you have slack channel already created, then ask your slack admin to give you the token for that channel.

Option 2. Ask your slack admin to create a new channel and get the token for that channel.

I. In Team Subdomain: type the name of <yourteam> as mentioned in my last post

2. copy paste the Slack Token you got from option 1 or 2, in Integration Token edit box. Then copy the channel name from option 1 or 2 as #<yourchannel> name and test connection by clicking on Test Connection button. And OR

If you setup everything correctly then it should have worked. Did you check the Jenkins log? Also see if you have any network or firewall setting that might preventing it to connect. If nothing works then ask your Slack Admin to regenerate a new token for your channel and then update the token in your settings as I mentioned in my previous post and try again.

It appears that the plugin does not correctly replace environment variables when it sends out "started" messages. For example, ${COMMIT_BRANCH} is not resolved for the started message, but it is on success:

Thanks for developing this useful plugin! I have a small suggestion. I use Matrix Jobs often and it used to be the case (at least in version 1.8) that I'd get one notification per job. As of 2.2 I get one notification per job configuration which is way, way too verbose. Is there a way to get back the previous behaviour? Thanks!

I can not access this page due to not having this plugin installed. But searching the wiki I find this https://plugins.jenkins.io/job-dsl and the syntax clearly IS different!

And also your error message

ERROR: (script, line 145) No signature of method: baseUrl() is applicable for argument types: (java.lang.String)

shows clearly that there is no method baseUrl.

Quoting the wiki for the Syntax:

Basics

The DSL allows the definition of a job, and then offers a useful set of functions to configure common Jenkins items. A configure is available to give direct access to the config.xml before generating the job. The script is groovy code, which can be very powerful. Here's an example to create a job for each branch in a git repo:

Since, I upgraded the plugin version from 2.0 to 2.3, I got the error bellow each one I hit the button "Test connection" :

java.lang.NoClassDefFoundError: Could not initialize class org.apache.http.conn.ssl.SSLConnectionSocketFactory
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:912)
at jenkins.plugins.slack.StandardSlackService.getHttpClient(StandardSlackService.java:200)
at jenkins.plugins.slack.StandardSlackService.publish(StandardSlackService.java:132)
at jenkins.plugins.slack.StandardSlackService.publish(StandardSlackService.java:95)
at jenkins.plugins.slack.SlackNotifier$DescriptorImpl.doTestConnection(SlackNotifier.java:510)
at java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:625)
at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:343)
at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:184)
at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:117)
at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:129)
at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58)
at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:715)
Caused: javax.servlet.ServletException