Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slack publish failed, response code 404 #480

Closed
amit-o opened this issue Jan 17, 2019 · 43 comments
Closed

Slack publish failed, response code 404 #480

amit-o opened this issue Jan 17, 2019 · 43 comments

Comments

@amit-o
Copy link

amit-o commented Jan 17, 2019

I'm trying to setup slack integration on a docker running in localhost.
When trying to publish or test connection in the settings, I'm getting this in the logs:

Jan 17, 2019 9:37:55 AM jenkins.plugins.slack.StandardSlackService publish
WARNING: Slack post may have failed. Response: null
Jan 17, 2019 9:37:55 AM jenkins.plugins.slack.StandardSlackService publish
WARNING: Response Code: 404

The same configurations are working in a non-docker configurations


    slackNotifier:
      tokenCredentialId: slack-token
      teamDomain: <workspace>
      baseUrl: https://<workspace>.slack.com/services/hooks/jenkins-ci/  
 credentials:
    system:
      domainCredentials:
            - string:
                scope: GLOBAL
                id: slack-token
                secret: ${SLACK_TOKEN}
@timja
Copy link
Member

timja commented Jan 17, 2019

Hi don't set teamDomain and baseUrl

only set teamDomain, may or may not be your issue.

But docker vs non docker probably isn't the issue

@amit-o
Copy link
Author

amit-o commented Jan 17, 2019

I've tried setting teamDomain only and baseUrl only, still the same issue

@timja
Copy link
Member

timja commented Jan 17, 2019

is the slack token correct?

@amit-o
Copy link
Author

amit-o commented Jan 17, 2019

Yes, I've posted manually with curl and token and the message was sent successfully

@timja
Copy link
Member

timja commented Jan 17, 2019

is it correct in jenkins though?
if you add a credential manually in the ui and select that one does it work?

@amit-o
Copy link
Author

amit-o commented Jan 17, 2019

Tried putting it in through the UI and deselected the credentialId, same error.

@timja
Copy link
Member

timja commented Jan 17, 2019

what about with a separate credential?

@amit-o
Copy link
Author

amit-o commented Jan 17, 2019

Do you mean a different slack token?
If so, just tried it and still no dice

@gregbishop
Copy link

I actually get this issue as well. What is particularly weird about it is that it only seems to fail when I send a message to certain users. It seems to be only newer users at the company (age of slack account may be a red herring, but I don't know). At this point I have no idea what else to do.

@Jalle19
Copy link

Jalle19 commented Jan 23, 2019

Seeing this problem as well, it started happening quite recently (less than a week ago)

@Jalle19
Copy link

Jalle19 commented Jan 23, 2019

WTF, in our case the problem was that someone (or Slack themselves?) had disabled the Jenkins CI app from Slack's integration settings. Clicked "enable" and it started working.

@timja
Copy link
Member

timja commented Jan 23, 2019

@Jalle19 That could happen if the person who previously added it had their slack account disabled

@esproul
Copy link

esproul commented Feb 6, 2019

I am having the same issue. I am unable to successfully "Test Connection". I have an "Outgoing Webhook Token" and "Outgoing Webhook URL Endpoint" set under "Slack Webhook Settings" (I get warnings if I leave either one blank). Further down, under "Global Slack Notifier Settings" I have:

  • Slack compatible app URL: (blank)
  • Team subdomain: (set to our Slack subdomain)
  • Integration Token Credential ID: set as Secret Text type per README.md#security
  • Is Bot User? is unchecked
  • Channel or Slack ID: set to our desired channel

When I try to test the connection, I see in the server log:

Feb 06, 2019 2:44:44 PM jenkins.plugins.slack.StandardSlackService publish
WARNING: Slack post may have failed. Response: null
Feb 06, 2019 2:44:44 PM jenkins.plugins.slack.StandardSlackService publish
WARNING: Response Code: 404

Jenkins 2.163, Slack plugin 2.15

@timja
Copy link
Member

timja commented Feb 6, 2019

Is the slack app integrated into at least one channel?

@esproul
Copy link

esproul commented Feb 6, 2019

Yes, I have one active configuration, into the same channel configured in the global notifier settings in Jenkins.

@timja
Copy link
Member

timja commented Feb 6, 2019

check your team domain is just the team name and not the full name
try regenerate the token

not really sure sorry, just check it's all been setup right

@esproul
Copy link

esproul commented Feb 6, 2019

Team subdomain is just the subdomain, no ".slack.com". I regenerated the token and updated it in Jenkins, but no change, still 404.

@esproul
Copy link

esproul commented Feb 6, 2019

Downgrading Slack notification plugin to 2.6 (the last working version I've been trying to upgrade from), I now see:

Feb 06, 2019 4:52:29 PM jenkins.plugins.slack.StandardSlackService publish
WARNING: Slack post may have failed. Response: no_active_hooks
Feb 06, 2019 4:52:29 PM jenkins.plugins.slack.StandardSlackService publish
WARNING: Response Code: 404

If I restore my integration token to the global config, it works.

@timja
Copy link
Member

timja commented Feb 6, 2019

interesting, i can't see anything around there that should have broken it
so on 2.6 with a credential it works properly and on 2.15 its broken?

@esproul
Copy link

esproul commented Feb 6, 2019

On 2.6 with an integration token (no credential ID) it works. On 2.15, regardless of any settings (with/without token, with/without credential ID), it doesn't work for me.

@saamorim
Copy link

saamorim commented Feb 6, 2019

For me, with the version 2.15 I if I use the tokenCredentialId I have the 404 reported before. The work around for me was to use the withCredentials.

Non working version:

slackSend teamDomain: 'domain', channel: 'pipeline-cicd', tokenCredentialId: 'slackCredentials',  color: 'danger', message: 'Not so good message from Jenkins Pipeline'

Working version:

withCredentials([string(credentialsId: 'slack-credentials', variable: 'slackCredentials')]) {
    slackSend teamDomain: 'domain',
        channel: 'pipeline-cicd', 
        token: slackCredentials, 
        color: 'danger',
        message: 'Not so good message from Jenkins Pipeline'
}

@timja
Copy link
Member

timja commented Feb 6, 2019

I'm wondering if there's some encoding issue in the secret

Would need to log the request to see what the token is,
You can either try setting a log recorder for org.apache.http.wire FINE
Or i'll have a debug build ready shortly

@timja
Copy link
Member

timja commented Feb 6, 2019

If you change jenkins.plugins.slack.StandardSlackService to fine it will be logged
can you compare both versions please

"Posting: to " + roomId + " on " + teamDomain + " using " + url + ": " + attachments.toString() + " " + color
It'll be in the URL

@gmsa
Copy link

gmsa commented Feb 7, 2019

I had the same problem and managed to get it working.
You need to set the integration token as a jenkins credential ID. The integration token input field is there, but seems to be ignored by the plugin.

@esproul
Copy link

esproul commented Feb 7, 2019

@gmsa do you mean setting the integration token as the "secret text" of the jenkins credential?

@gmsa
Copy link

gmsa commented Feb 7, 2019

@esproul yes

@esproul
Copy link

esproul commented Feb 7, 2019

Cool, 2.15 now works, and I didn't have to do anything; after this most recent upgrade I have a "Migrated Slack Token" credential ID. "Test Connection" succeeds. I don't know if this made a difference, but yesterday after downgrading back to 2.6, I noticed a number of jobs that had the integration token in their job config, when it didn't need to be (none of my jobs need to override the global settings.) I went through and cleaned those out; not sure if that would have interfered with the automatic migration of the global token or not.

@esproul
Copy link

esproul commented Feb 7, 2019

@timja @gmsa thank you for your help!

@timja timja closed this as completed Mar 18, 2019
@tiendungitd
Copy link

I got the same issue with version 2.22, integration token as a jenkins credential ID is work for me. But could this issue fix in new version?
Seen like the version 2.14 work well without the workaround above?

@timja
Copy link
Member

timja commented May 28, 2019

what specifically was your issue @tiendungitd? there's many things that can go wrong and cause that issue

@tiendungitd
Copy link

@timja : In build job configuration, the "integratoin token" field have been ingore. under "Slack Notifications" I have:

- Slack compatible app URL: https://{workspace}.slack.com/services/hooks/jenkins-ci/
- Team subdomain: (blank)
- Integration Token: cu6lsj1t9Eh81119Q8kyT0f
- Integration Token Credential ID: none
- Is Bot User? is unchecked
- Channel or Slack ID: #general

I got failed when click test connection, look at system log I found the error:
Slack post may have failed. Response: no_active_hooks, then I using "Integration Token Credential ID" fix the issue, but I expect using "Integration Token" field

And if I setting Slack notification is:

- Slack compatible app URL: (blank)
- Team subdomain: my-workspace
- Integration Token: cu6lsj1t9Eh81119Q8kyT0f
- Integration Token Credential ID: none

I got success when click Test connection, event I type incorrect token and of course my job build not send anything to slack.

I'm using Jenkins 2.164.2. Slack plugin version 2.22.

@JamesMahy
Copy link

JamesMahy commented May 30, 2019

Hi,

I'm running 2.23.
There is no "Integration Token" field (as per the instructions shown on slack)

I've installed the Slack Integration and also tried with a bot using an incoming hook. Neither work.

If I use

  • Slack compatible app URL (optional) = empty
  • Subdomain = myslackservername,
  • Integration Token Credential ID = Client Token, Secret
  • Is Bot User = Checked,
  • Channel = #notifications

I get

[JobName #35] will send OnSuccessNotification because build matches and user preferences allow it
and no error but nothing in the slack channel

If I use

I get

[JobName #36] will send OnSuccessNotification because build matches and user preferences allow it May 30, 2019 3:25:56 PM WARNING jenkins.plugins.slack.StandardSlackService publish Slack post may have failed. Response: May 30, 2019 3:25:56 PM WARNING jenkins.plugins.slack.StandardSlackService publish Response Code: 302

If I use

I get
[JobName #37] will send OnSuccessNotification because build matches and user preferences allow it May 30, 2019 3:28:20 PM INFO jenkins.plugins.slack.logging.SlackNotificationsLogger info [JobName #37] Exception attempting Slack notification: the token with the provided ID could not be found and no token was specified

If I use

I get
[JobName #38] will send OnSuccessNotification because build matches and user preferences allow it May 30, 2019 3:30:13 PM WARNING jenkins.plugins.slack.StandardSlackService publish Slack post may have failed. Response: May 30, 2019 3:30:13 PM WARNING jenkins.plugins.slack.StandardSlackService publish Response Code: 302

There aren't any combinations in which this works - but I can manually call the hook using curl.
Also the documentation is out of date or there is a missing Integration token field (assuming out of date as "Slack compatible app URL (optional)" says "Base URL" in the documentation.

@timja
Copy link
Member

timja commented May 30, 2019

you probably want bot user false

@JamesMahy
Copy link

Checked or unchecked it doesn't solve the problem in any scenario. I get "302" and no response.

@timja
Copy link
Member

timja commented May 30, 2019

can you screenshot please?

@JamesMahy
Copy link

I get 302 if I hit "Test"
I get 404 if I try following a build.

download (4)
download (3)

@JamesMahy
Copy link

These are the instructions on Slack, which are no longer viable.
image

@timja
Copy link
Member

timja commented May 30, 2019

No the slack instructions are wrong, I asked them to update it but it didn't happen...

Team subdomain
Credential ID
channel

The instructions on the README should be up to date

@JamesMahy
Copy link

Unfortunately it doesn't work with any settings.

@xorgnz
Copy link

xorgnz commented Jun 26, 2019

I'm having a similar issue. Is there anything I can do to get it to spit out more log info so that I can try and make sense of this? Or should I break out the network analyzer to see what's going back and forth?

Running "test connection" in the admin just lists "Failure" in red. In the logs I see the same 404 issue described here. I'm running version 2.27 of the plugin

@timja
Copy link
Member

timja commented Jun 26, 2019

@xorgnz you can add a log recorder to this class:
jenkins.plugins.slack.StandardSlackService
also see:
#480 (comment)

@xorgnz
Copy link

xorgnz commented Jun 27, 2019

Thanks! That was very helpful. I appear to be working (seems the plugin hadn't installed properly)

@ckime-ibm
Copy link

The withCredentials solution did not work for me, in a Jenkins pipeline job.

The "global"/default credentials specified in the Slack plug-in configuration did not seem to work. I created a new global credentials, and specified with tokenCrendentialId and finally had a successful slackSend.

My git diff in case it helps anyone:

                     slackSend channel: "#slack-channel-name",
-                                message: "Build message - SUCCESS",
-                                color: "good",
-                                baseUrl: "https://my-domain.slack.com/services/hooks/jenkins-ci/",
-                                token: "${SLACK_CHANNEL_TOKEN}"
+                        teamDomain: "my-domain",
+                        message: "Build message with tokenCredentialID - SUCCESS",
+                        color: "good",
+                        // Do not specify baseURL w/Channel.  
+                        //baseUrl: "https://ibm-ai-apps.slack.com/services/hooks/jenkins-ci/",
+                        // 404 with token, works with this tokenCredentialId.
+                        //token: "${SLACK_CHANNEL_TOKEN}"
+                        tokenCredentialId: "ai-apps-slack-token"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests