Open pporee opened 3 years ago
Please provide more information, i.e. scopes, what resolution strategy you have configured in your global config?
@timja Added scopes, creds and my config as code, if you need more tell me :). Regards
the resolution strategy for slack IDs? it's in the advanced settings on the global configuration
As my app is part of my organisation i only found that parameter under my app scope. Is it what you need or do i need to ask to slack administrators ?
No in your jenkins configuration, system configuration page
sorry i can't find more informations, i gave you all i got :(
Talked to Slack about the same problem. They have changed the way their REST API receives the OAuth token. Because of that the plugin does not work with getting the emails.
https://api.slack.com/changelog/2020-11-no-more-tokens-in-querystrings-for-newly-created-apps
I do not know to program in java but if someone that can , would change the way the OAuth token is sent to Slack then it would work @timja
A couple of things you could try:
def userIds = slackUserIdsFromCommitters()
def userIdsString = userIds.collect { "<@$it>" }.join(' ')
it is also documented here.
Finally, FYI, you can limit the number of git commits shown by git log
like this:
git log -1 --format="%ae"
No need to bother the head
command👍
Faced the same issue today. Do you have any updates on it?
+1 Experiencing the same issue.
My app has the required permissions and the Email User resolver option is enabled on Jenkins.
I found the same issue. My issue was that when I printed out the git committer it was a jenkins user. When I added
options {
skipDefaultCheckout()
}
stages {
stage('Checkout') {
steps { checkout scm }
}
}
then I had a real committer.
We ran into this same issue. We're not able to resolve Slack userIds from email.
Slack email User ID Resolver
is checkedusers:read
and users:read.email
I've tried with a simple snippet like this one
def sendSlackNotification() {
// test with 'slackUserIdFromEmail'
def lastCommitterEmail = sh(returnStdout: true, script: 'git log --format="%ae" | head -1').trim()
echo "commit author ${lastCommitterEmail}"
def slackUserId = slackUserIdFromEmail("${lastCommitterEmail}")
slackSend(color: "good", message: "@${slackUserId} 'slackUserIdFromEmail' message", channel: channel)
// test with 'slackUserIdsFromCommitters'
def userIds = slackUserIdsFromCommitters()
def userIdsString = userIds.collect { "<@$it>" }.join(' ')
slackSend(color: colorCode, message: "${userIdsString} 'slackUserIdsFromCommitters' message", channel: channel)
}
but I get nothing, see image below.
If I use the Slack userId directly it does work i.e.
def sendSlackNotification() {
// test with userId
def userId = "@{my-slack-user-id}"
slackSend(color: colorCode, message: "${userId} 'userId' message", channel: channel)
}
then it does work. Any hint? In master node's /var/log/jenkins/jenkins.log
file I can only see this warning, nothing more useful
2024-02-26 15:19:56.398+0000 [id=17689022] WARNING o.j.r.u.AnonymousClassWarnings#warn: Attempt to (de-)serialize synthetic class jenkins.plugins.slack.user.EmailSlackUserIdResolver$$Lambda$621/540202168 in file:/var/lib/jenkins/plugins/slack/WEB-INF/lib/slack.jar; see: https://jenkins.io/redirect/serialization-of-anonymous-classes/
We experience similar issue as posted above with the more recent versions as well:
2.440.2
684.v833089650554
Enabled additional logging as described here but in the resulting log there are no details about the api calls being made by slack plugin to slack and their results. It only posts log messages like the one below:
Apr 23, 2024 3:39:19 PM FINE jenkins.plugins.slack.StandardSlackService
Posting: to #channel_name on : {"attachments":[{"fallback":"null, message text","color":"#FFFF00","fields":[{"short":false,"value":"null, message text"}],"mrkdwn_in":["pretext","text","fields"]}],"link_names":"1","unfurl_links":"true","unfurl_media":"true","channel":"#channel_name","as_user":"true"}
Apr 23, 2024 3:39:20 PM FINE jenkins.plugins.slack.StandardSlackService
Posting succeeded
Any guidance on how to troubleshoot it further?
Version report
Jenkins 2.277.3 Slack Notification Plugin 2.48
Issue
Hi,
I got the same issue reported here https://github.com/jenkinsci/slack-plugin/issues/763, the func return null and no errors or debug informations are available.
Scopes
Here the scopes for my slack app. chat:write files:write users:read users:read.email
Token
Config as Code
thanks for your help. Below my code:
Result:
Reproduction steps
I tested directly with my slack email in the
slackUserIdFromEmail
function but got the same result.