Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slack Jenkins plugin not working

I'm running jenkins from a .bat file because I need some apps to be able to perform some service operations that otherwise, from the service, would be impossible to do.

I have installed the jenkins plugin in Slack. Followed the instructions and go to configure the plugin.

Because I'm running it for now locally I have the following configuration:

  • Base URL: http://127.0.0.1:7061/
  • Team subdomain: weatherwindowsapp
  • Integration token: gk2aDYzJP8DQ2mGssS1Sssm1
  • Channel: #testchannel

If I click in the "Test connection" button at the bottom the following error is yielded to the console running jenkins:

    [0m[33mApr 18, 2017 3:53:29 PM jenkins.plugins.slack.StandardSlackService publish
WARNING: Response Code: 403
[0m[33mApr 18, 2017 4:00:33 PM hudson.security.csrf.CrumbFilter doFilter
WARNING: No valid crumb was included in request for /gk1aDYmKI6DQ3mGsuZ1fevm5. Returning 403.
[0m[33mApr 18, 2017 4:00:33 PM jenkins.plugins.slack.StandardSlackService publish
WARNING: Slack post may have failed. Response: <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 403 No valid crumb was included in the request</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /gk1aDYmKI6DQ3mGsuZ1fevm5. Reason:
<pre>    No valid crumb was included in the request</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>

</body>
</html>

[0m[33mApr 18, 2017 4:00:33 PM jenkins.plugins.slack.StandardSlackService publish
WARNING: Response Code: 403
[0m

If I change the Base URL to "/" I get this response:

  [0m[33mApr 18, 2017 4:26:21 PM jenkins.plugins.slack.StandardSlackService publish
WARNING: Error posting to Slack
java.lang.IllegalStateException: Target host is null
        at org.apache.http.util.Asserts.notNull(Asserts.java:46)
        at org.apache.http.impl.client.InternalHttpClient.determineRoute(InternalHttpClient.java:125)
        at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
        at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
        at org.apache.http.impl.client.CloseableHttpClient.execute(Closeabl

I followed the instructions step by step, tried different Base URl without any success.

like image 821
Fritjof Berggren Avatar asked Apr 18 '17 15:04

Fritjof Berggren


People also ask

How do I enable Slack notifications in Jenkins?

In your Jenkins dashboard, click on Manage Jenkins from the left navigation. Click on Manage Plugins and search for Slack Notification in the Available tab. Click the checkbox and install the plugin.


1 Answers

Was dealing with the same issue. So I've found simple workaround (for integration with slack.com. Didn't check for other systems):

  1. You need to specify direct URL for notifications in Jenkins for your slack system Base URL - https://your-sub-domain.slack.com/services/hooks/jenkins-ci/
  2. Populate other required fields (Team Subdomain, Integration Token, Chanel)
  3. Click Test Connection button

After following this steps you may solve the issue

like image 150
JohnD Avatar answered Oct 08 '22 17:10

JohnD