How to resolve a UserID from email
Your checklist for this issue
-
[X] Jenkins version 2.204.1
-
[X] Plugin version 2.35
-
[X] OS Ubuntu
Description
My Goal: For the slack plugin to send a message to a specific channel doing a highlight of a user. The input information to the slack plugin is the email address the user has.
I have created an Slack app and added a bot user. I have added permissions to it: chat:write users:read users:read.email users.write
The bot can successfully write to the channel I want. But it does not resolve the email address to the userID which is needed to do a mention.
I have activated the options: Custom slack app bot user - Checked User ID Resolver - Slack email user ID resolver
The help text for the user ID resolver is: "Slack User IDs will be resolved by associated email address using the users.lookupByEmail API method. Requires using a bot user."
The slack documentation for this (https://api.slack.com/methods/users.lookupByEmail) says: "Custom bot users cannot use this method."
Is there a difference between "bot user" and "Custom slack app bot user"?
I am testing using this in my jenkinsfile:
slackSend channel: "${slackChannel}", message: "${env.JOB_BASE_NAME} failed. Last commit was from <@[email protected]> (<${env.BUILD_URL}|Open>)"
The output in slack is:
orc-pipeline failed. Last commit was from <@[email protected]> (Open)
The output in Jenkins is:
Slack Send Pipeline step running, values are - baseUrl: <empty>, teamDomain: MYDOMAIN, channel: my-channel, color: <empty>, botUser: true, tokenCredentialId: CREDENTIALID, notifyCommitters: false, iconEmoji: <empty>, username: <empty>
Am I formatting this incorrect or have I missed something?
If I user the UserID directly it works, for example
slackSend channel: "${slackChannel}", message: "${env.JOB_BASE_NAME} failed. Last commit was from <@APQRL6MQC> (<${env.BUILD_URL}|Open>)"
This would output in Slack like this (and highlight/mention the user)
orc-pipeline failed. Last commit was from @My Real Name(Open)
So the issue seem to be in making the slack plugin resolve the an email address to an userID. I feel like maybe the format <@[email protected]> is not correct?
I found this closed PR with other people wanted to know more on how to use this features: https://github.com/jenkinsci/slack-plugin/pull/178
I found no mention in the README on how to use it. More information here would be great.
See #651
See #651
While the issue was the same in #651 the solution posted was "I selected a "User ID resolver" checkbox and it works, thanks a lot!" I already have this checked and have not got it working. I would love more information on how to format the message to get this to work if that is the issue.
I'm having the same problem too, notifyCommiters doesn't work to me
ensure that the git config user.email is set correctly before commiting and that it is the same as the slack email.
ensure that the
git config user.emailis set correctly before commiting and that it is the same as the slack email.
I have verified this and I'm having the same issue.