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-API Notifications no longer working #545

Closed
tracom1 opened this issue Mar 26, 2019 · 27 comments
Closed

Slack-API Notifications no longer working #545

tracom1 opened this issue Mar 26, 2019 · 27 comments

Comments

@tracom1
Copy link

tracom1 commented Mar 26, 2019

We've upgraded our slack-plugin from 2.18 to 2.19, and can no longer publish notifications to our slack channels. We receive the following error:

12:59:51  ERROR: Slack notification failed with exception: java.lang.IllegalArgumentException: the token with the provided ID could not be found and no token was specified

We are configuring and using the token by using the following XML configuration:

<tokenCredentialId>slack-api-token</tokenCredentialId>

We've also tried setting the teamDomain, with no success. Since this worked prior to upgrading to 2.19, I'm guessing this is related to the folder credential support added in PR-541(#541)

@timja
Copy link
Member

timja commented Mar 26, 2019

Are you using freestyle jobs or pipeline?

What scope is the credential set at?

@tracom1
Copy link
Author

tracom1 commented Mar 26, 2019

We're using pipeline, and the credential is set globally.

@timja
Copy link
Member

timja commented Mar 26, 2019

For the credential can you check the scope please?
image

URL something like:
https://<jenkins-url>/credentials/store/system/domain/_/credential/slack-token/update

@tracom1
Copy link
Author

tracom1 commented Mar 26, 2019

Scope is System (Jenkins and nodes only).

@timja
Copy link
Member

timja commented Mar 26, 2019

Needs to be updated to global, System means it's not available to jobs

We're now Job context aware to allow supporting folder credentials, it has an impact that any previously working System credentials won't work.

@tracom1
Copy link
Author

tracom1 commented Mar 26, 2019

Ok, that's good to know. I'll try that

@esproul
Copy link

esproul commented Apr 1, 2019

I just updated from 2.18 to 2.20 and I am still seeing the error that the OP reported. I double-checked that my existing credential is global-scope and is called "Migrated slack token". When I test connection from the global Jenkins configuration, it works, but from a job (even one which contains no overrides of the global settings), it fails with the illegal argument exception.

I note that the menu for "Integration Token Credential ID" has no options other than "none". I believe I should be able to select my existing credential there, but I'm not sure if that's just for overriding too.

@timja
Copy link
Member

timja commented Apr 1, 2019

@esproul #545 (comment)

@esproul
Copy link

esproul commented Apr 1, 2019

@timja I'm confused; I saw that comment, and I already checked that my credential is set to global scope, not system. Did I miss something?

@timja
Copy link
Member

timja commented Apr 1, 2019

can you post a screenshot please of your credential config
the symptoms are what would normally happen if the credential was set to System scope

@esproul
Copy link

esproul commented Apr 1, 2019

jenkins_cred

@timja
Copy link
Member

timja commented Apr 1, 2019

Click the "migrated slack token" credential and then click update

@esproul
Copy link

esproul commented Apr 1, 2019

I will soon; I had to downgrade the plugin to get notifications working again, and as soon as there is a lull I will upgrade the plugin again and try the update on the credential. Thanks for the help!

@timja
Copy link
Member

timja commented Apr 1, 2019

you can update the credential separately, Global will work on both versions of the plugin

@esproul
Copy link

esproul commented Apr 1, 2019

Oh, hah. In the Update screen for the token, "Scope" was set to System there. I missed that before, thinking the "global" that I saw on the main Credentials screen meant the token was global. I've set it to Global now so it will probably work when I re-upgrade the plugin. Thanks again.

@esproul
Copy link

esproul commented Apr 2, 2019

@timja Confirmed, after change to token scope, 2.20 works as expected. Sorry for the noise, but I appreciate you clearing up my confusion.

@jsoref
Copy link
Contributor

jsoref commented Jun 10, 2019

@timja : this isn't cool. If you make a breaking change like this, you must mark it as breaking so that when people upgrade they will get a nice red warning about incompatible settings.

For example:

SSH SlavesAllows to launch agents over SSH, using a Java implementation of the SSH protocol.

Warning: the new version of this plugin claims to use a different settings format than the installed version. Jobs using this plugin may need to be reconfigured, and/or you may not be able to cleanly revert to the prior version without manually restoring old settings. Consult the plugin release notes for details.

@timja
Copy link
Member

timja commented Jun 11, 2019

@jsoref there was a bug in the migration, it should have been compatible.
It would be marked incompatible if it was intentionally incompatible.

believe me there's a number of methods and code I want to remove in this plugin but I'm keeping them for backwards compatibly.

90% of the review I do on changes is for backwards compatibility fixes

@darmbrust
Copy link

What is the actual fix for this? I just tried integrating with this plugin, and am still getting the same error. I'm injecting the token as a global secret using the Configuration As Code plugin (into my docker image for jenkins), and the end result is

ERROR: Slack notification failed with exception: java.lang.IllegalArgumentException: the token with the provided ID could not be found and no token was specified

Even though the specified token id is correct in the debug output above:
tokenCredentialId: slack-token

And a global credential exists with the correct value.

@darmbrust
Copy link

It turns out, I still had a bug in my docker build, that was causing the token "secret" portion to be an empty string, instead of the correct value. But the error message provided when this happened was still wrong - it shouldn't say that the provided ID could not be found, because it could be found - it is just that the provided ID had the incorrect (empty) value in my case.

@timja
Copy link
Member

timja commented Aug 13, 2019

Feel free to send a PR for this edge case @darmbrust
The reason you're confused is that two error messages are combined into one.
it could either be cred not found or empty token.

@dashfwd
Copy link

dashfwd commented Aug 16, 2019

To all reading this thread ... upgrading to version 2.30 of the plugin completely broke Slack notifications (w/Jenkins ver. 2.189). No amount changing credential scopes worked. In fact, I wasn't able to use any existing credentials, and when I tried to create new ones I wasn't able to select the new one that I created.

Solution that worked for me: Revert to Slack plugin version 2.28 and re-select credentials, and then things worked fine again.

@timja
Copy link
Member

timja commented Aug 16, 2019

File a new issue please

@dashfwd
Copy link

dashfwd commented Aug 16, 2019

Done: #609

@evertonevaristo
Copy link

Hello All, I'm still facing this issue at Jenkins 2.204.1 and plugin 2.36, does anyone know how to solve this?

@jsoref
Copy link
Contributor

jsoref commented Feb 4, 2020

@evertonevaristo: Please file a new issue. (This stuff is apparently moderately fragile as it has since been broken and fixed again at least once before, c.f. #545 (comment).)

@evertonevaristo
Copy link

@jsoref thank you!

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

7 participants