jenkinsci / slack-plugin

A Jenkins plugin for posting notifications to a Slack channel
https://plugins.jenkins.io/slack/
672 stars 413 forks source link

DMs stopped working after slack upgrade #941

Open AdamBrousseau opened 5 months ago

AdamBrousseau commented 5 months ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.426.2 OS: Linux - 5.4.0-169-generic Java: 11.0.16.1 - Eclipse Adoptium (OpenJDK 64-Bit Server VM) --- ansible-tower:0.16.0 ansicolor:1.0.4 ant:497.v94e7d9fffa_b_9 antisamy-markup-formatter:162.v0e6ec0fcfcf6 apache-httpcomponents-client-4-api:4.5.14-208.v438351942757 apache-httpcomponents-client-5-api:5.3-1.0 appscan:1.2.0 artifactory:4.0.0 authentication-tokens:1.53.v1c90fd9191a_b_ authorize-project:1.7.1 badge:1.9.1 blueocean:1.27.8 blueocean-autofavorite:1.2.5 blueocean-bitbucket-pipeline:1.27.8 blueocean-commons:1.27.8 blueocean-config:1.27.8 blueocean-core-js:1.27.8 blueocean-dashboard:1.27.8 blueocean-display-url:2.4.2 blueocean-events:1.27.8 blueocean-executor-info:1.27.8 blueocean-git-pipeline:1.27.8 blueocean-github-pipeline:1.27.8 blueocean-i18n:1.27.8 blueocean-jira:1.27.8 blueocean-jwt:1.27.8 blueocean-personalization:1.27.8 blueocean-pipeline-api-impl:1.27.8 blueocean-pipeline-editor:1.27.8 blueocean-pipeline-scm-api:1.27.8 blueocean-rest:1.27.8 blueocean-rest-impl:1.27.8 blueocean-web:1.27.8 bootstrap5-api:5.3.2-3 bouncycastle-api:2.30.1.77-225.v26ea_c9455fd9 branch-api:2.1144.v1425d1c3d5a_7 build-failure-analyzer:2.4.2 build-keeper-plugin:19.va_df8a_2c65123 build-name-setter:2.4.0 build-pipeline-plugin:1.5.8 build-timeout:1.31 build-user-vars-plugin:1.9 build-with-parameters:76.v9382db_f78962 caffeine-api:3.1.8-133.v17b_1ff2e0599 checks-api:2.0.2 claim:516.v36293563731d cloud-stats:320.v96b_65297a_4b_b_ cloudbees-bitbucket-branch-source:848.v42c6a_317eda_e cloudbees-disk-usage-simple:203.v3f46a_7462b_1a_ cloudbees-folder:6.858.v898218f3609d command-launcher:107.v773860566e2e commons-lang3-api:3.13.0-62.v7d18e55f51e2 commons-text-api:1.11.0-95.v22a_d30ee5d36 compact-columns:1.185.vf3851b_4d31fe conditional-buildstep:1.4.3 config-file-provider:959.vcff671a_4518b_ configuration-as-code:1763.vb_fe9c1b_83f7b copyartifact:722.v0662a_9b_e22a_c credentials:1311.vcf0a_900b_37c2 credentials-binding:642.v737c34dea_6c2 cvs:2.19.1 dark-theme:416.v535839b_c4e88 dashboard-view:2.495.v07e81500c3f2 data-tables-api:1.13.8-2 delivery-pipeline-plugin:1.4.2 deploy:1.16 description-setter:1.10 disk-usage:1.2 display-url-api:2.200.vb_9327d658781 docker-commons:439.va_3cb_0a_6a_fb_29 docker-java-api:3.3.1-79.v20b_53427e041 docker-plugin:1.5 docker-workflow:572.v950f58993843 downstream-buildview:69.v16da_b_2c36f6c dtkit-api:3.0.2 durable-task:543.v262f6a_803410 dynamic_extended_choice_parameter:1.0.1 echarts-api:5.4.3-2 elastic-axis:464.va_7ed499b_9d75 email-ext:2.103 emailext-template:1.5 embeddable-build-status:412.v09da_db_1dee68 envinject:2.908.v66a_774b_31d93 envinject-api:1.199.v3ce31253ed13 extended-read-permission:53.v6499940139e5 external-monitor-job:215.v2e88e894db_f8 favorite:2.4.3 file-operations:131.v32b_e7824fe95 font-awesome-api:6.5.1-1 ghprb:1.42.2 git:5.2.1 git-client:4.6.0 git-server:99.va_0826a_b_cdfa_d github:1.37.3.1 github-api:1.318-461.v7a_c09c9fa_d63 github-branch-source:1767.va_7d01ea_c7256 google-oauth-plugin:1.330.vf5e86021cb_ec gradle:2.9 groovy:457.v99900cb_85593 groovy-postbuild:2.5 gson-api:2.10.1-15.v0d99f670e0a_7 h2-api:11.1.4.199-12.v9f4244395f7a_ handy-uri-templates-2-api:2.1.8-22.v77d5b_75e6953 htmlpublisher:1.32 http_request:1.18 hudson-pview-plugin:1.8 ibm-ucdeploy-publisher:1.2.7 icon-shim:3.0.0 instance-identity:185.v303dc7c645f9 ionicons-api:56.v1b_1c8c49374e ivy:2.5 jackson2-api:2.16.1-373.ve709c6871598 jakarta-activation-api:2.0.1-3 jakarta-mail-api:2.0.1-3 javadoc:243.vb_b_503b_b_45537 javax-activation-api:1.2.0-6 javax-mail-api:1.6.2-9 jaxb:2.3.9-1 jdk-tool:73.vddf737284550 jenkins-design-language:1.27.8 jersey2-api:2.41-133.va_03323b_a_1396 jira:3.11 jjwt-api:0.11.5-77.v646c772fddb_0 jnr-posix-api:3.1.18-1 job-dsl:1.87 job-import-plugin:3.6 jobConfigHistory:1229.v3039470161a_d join:1.21 jquery:1.12.4-1 jquery-ui:1.0.2 jquery3-api:3.7.1-1 jsch:0.2.8-65.v052c39de79b_2 json-api:20231013-17.v1c97069404b_e json-path-api:2.8.0-21.v8b_7dc8b_1037b_ junit:1252.vfc2e5efa_294f keep-slave-disconnected:1.0 kubernetes:4174.v4230d0ccd951 kubernetes-client-api:6.9.2-239.ve49a_3f285167 kubernetes-credentials:0.11 label-linked-jobs:6.0.1 ldap:711.vb_d1a_491714dc lockable-resources:1214.v1f595d4672da_ log-parser:2.3.1 login-theme:108.vf74a_83b_2238b_ mailer:463.vedf8358e006b_ mapdb-api:1.0.9-28.vf251ce40855d material-theme:0.5.2-rc100.6121925fe229 matrix-auth:3.2.1 matrix-combinations-parameter:1.3.3 matrix-project:822.v01b_8c85d16d2 matrixtieparent:1.2 maven-plugin:3.23 mercurial:1260.vdfb_723cdcc81 metrics:4.2.18-442.v02e107157925 mina-sshd-api-common:2.11.0-86.v836f585d47fa_ mina-sshd-api-core:2.11.0-86.v836f585d47fa_ mission-control-view:0.9.16 monitoring:1.95.0 multi-module-tests-publisher:1.44 next-build-number:1.8 nodelabelparameter:1.12.0 oauth-credentials:0.646.v02b_66dc03d2e offlineonfailure-plugin:1.0 okhttp-api:4.11.0-157.v6852a_a_fa_ec11 openshift-client:1.1.0.420.v8817277c1990 openshift-pipeline:1.0.57 openshift-sync:1.1.0.795.v95fa_27a_a_e287 pam-auth:1.10 parameter-separator:87.va_1816d0b_39d1 parameterized-trigger:787.v665fcf2a_830b_ perfpublisher:8.09 pipeline-aggregator-view:1.15 pipeline-build-step:540.vb_e8849e1a_b_d8 pipeline-github:2.8-155.8eab375ac9f8 pipeline-github-lib:42.v0739460cda_c4 pipeline-graph-analysis:202.va_d268e64deb_3 pipeline-groovy-lib:689.veec561a_dee13 pipeline-input-step:477.v339683a_8d55e pipeline-milestone-step:111.v449306f708b_7 pipeline-model-api:2.2168.vf921b_4e72c73 pipeline-model-declarative-agent:1.1.1 pipeline-model-definition:2.2168.vf921b_4e72c73 pipeline-model-extensions:2.2168.vf921b_4e72c73 pipeline-rest-api:2.34 pipeline-stage-step:305.ve96d0205c1c6 pipeline-stage-tags-metadata:2.2168.vf921b_4e72c73 pipeline-stage-view:2.34 pipeline-utility-steps:2.16.0 plain-credentials:143.v1b_df8b_d3b_e48 plugin-util-api:3.8.0 prism-api:1.29.0-10 project-build-times:1.2.1 pubsub-light:1.18 purge-build-queue-plugin:88.v23b_97b_f2c7a_d radiatorviewplugin:1.29 rebuild:327.v67ca_b_b_6cd42e resource-disposer:0.23 role-strategy:689.v731678c3e0eb_ run-condition:1.7 saferestart:0.7 saml:4.429.v9a_781a_61f1da_ schedule-build:502.v9379e178e65b_ scm-api:683.vb_16722fb_b_80b_ scoring-load-balancer:59.vf791549fa_989 script-security:1313.v7a_6067dc7087 sidebar-link:2.4.1 simple-theme-plugin:176.v39740c03a_a_f5 slack:684.v833089650554 slack-uploader:1.7 snakeyaml-api:2.2-111.vc6598e30cc65 sse-gateway:1.26 ssh:2.6.1 ssh-agent:346.vda_a_c4f2c8e50 ssh-credentials:308.ve4497b_ccd8f4 ssh-slaves:2.947.v64ee6b_f87b_c1 sshd:3.312.v1c601b_c83b_0e structs:325.vcb_307d2a_2782 subversion:2.17.3 support-core:1366.v9d076592655d tap:2.3 test-results-analyzer:0.4.0 testng-plugin:835.v51ed3da_fcc35 text-finder:1.26 text-finder-run-condition:6.vdf94e6f8d2c3 theme-manager:215.vc1ff18d67920 thinBackup:1.18 throttle-concurrents:2.14 timestamper:1.26 token-macro:400.v35420b_922dcb_ trilead-api:2.133.vfb_8a_7b_9c5dd1 uno-choice:2.8.0 variant:60.v7290fc0eb_b_cd view-job-filters:369.ve0513a_a_f5524 workflow-aggregator:596.v8c21c963d92d workflow-api:1283.v99c10937efcb_ workflow-basic-steps:1042.ve7b_140c4a_e0c workflow-cps:3835.vc2a_8f9167e92 workflow-durable-task-step:1313.vcb_970b_d2a_fb_3 workflow-job:1385.vb_58b_86ea_fff1 workflow-multibranch:770.v1a_d0708dd1f6 workflow-scm-step:415.v434365564324 workflow-step-api:639.v6eca_cd8c04a_a_ workflow-support:865.v43e78cc44e0d ws-cleanup:0.45 xunit:3.1.3 xvfb:1.2 zentimestamp:4.2 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Ubuntu 20.04 Slack plugin version 684.v833089650554 Slack client version 4.35.131 64-bit

Reproduction steps

Pipeline code to send a direct message

slackSend channel: "${SLACK_HANDLE}", color: 'warning', message: "MY MESSAGE"

Expected Results

Works for channels. No longer works for Direct messages to users. This was noticed after our corporate slack was onboarded to the new interface in November (2023). https://slack.com/help/articles/16764236868755-An-overview-of-Slacks-new-design

Actual Results

No message is sent, response null. This is from the Jenkins log (redacted sensitive info *****)

Jan 18, 2024 3:15:58 PM FINE jenkins.plugins.slack.StandardSlackService publish
Posting: to @***** on *****:  {"attachments":[{"fallback":"*****"}],"mrkdwn_in":["pretext","text","fields"]}],"link_names":"1","unfurl_links":"true","unfurl_media":"true","channel":"@*****","as_user":"true"}
Jan 18, 2024 3:15:58 PM WARNING jenkins.plugins.slack.StandardSlackService postToSlack
Slack post may have failed. Response: null
Jan 18, 2024 3:15:58 PM WARNING jenkins.plugins.slack.StandardSlackService postToSlack
Response Code: 400

Anything else?

No response

Are you interested in contributing a fix?

No response

timja commented 5 months ago

Have you tried sending that message to slack directly skipping Jenkins?

You haven't posted the full details of your integration, but if you are using bot user mode you can use this to test it in the UI: https://api.slack.com/methods/chat.postMessage

AdamBrousseau commented 5 months ago

We are using the "Jenkins - CI" slack app. This is interesting

This app was made by Slack.

This app was made by a member of the Slack team to help connect Slack with a third-party service; these apps may not be tested, documented, or supported by Slack in the way we support our core offerings, like Slack Enterprise Grid and Slack for Teams. You may provide feedback about these apps at feedback@slack.com.

Also interesting from the page you linked

Post to a direct message channel Posting to direct messages (also known as DMs or IMs) can be a little more complex, depending on what you actually are meaning to accomplish.

If you want your app's bot user to start a 1:1 conversation with another user in a workspace, provide the user's user ID as the channel value and a direct message conversation will be opened, if it hasn't already. Resultant messages and associated direct message objects will have a direct message ID you can use from that point forward, if you'd rather.

Bot users cannot post to a direct message conversation between two users using chat.postMessage. If your app was involved in the conversation, then it would be a multi-person direct message instead. Apps can post to direct message conversations between users when a shortcut or slash command belonging to that app is used in the conversation.

You will receive a channel_not_found error if your app doesn't have permission to enter into a DM with the intended user.

Passing a "username" as a channel value is deprecated, along with the whole concept of usernames on Slack. Please always use channel-like IDs instead to make sure your message gets to where it's going.

That deprecation link is from 2017 though so I don't think that is our issue.

What was happening before it broke, was a message was posted in your DM with the "slackbot" user [1], from the "jenkins-ci" APP[2]. Perhaps I need to send an email to Slack themselves?

[1] image [2] image

timja commented 5 months ago

I would create your own bot app, that app you are using is a legacy and and some features don’t work with it