Jenkins slack plugin: response 400 - but "test connection" works ok

Hi

I am trying to send slack notifications from jenkins. I installed the most recent version of the slack plugin. My (related) configuration as code is

credentials:
  system:
    domainCredentials:
    - credentials:
      - string:
          description: "Adzuna Slack Token"
          id: "slack-token"
          scope: GLOBAL
          secret: "{foo}"
jenkins:
  crumbIssuer: "strict"
unclassified:
  slackNotifier:
    botUser: false
    sendAsText: false
    teamDomain: "team-foo"
    tokenCredentialId: "slack-token"

I tested through “Dashboard → Manage Jenkins → System → Slack → Test connection”. It says “success” and it does send a message to slack

However, from my pipeline console output says

...
Slack Send Pipeline step running, values are - baseUrl: <empty>, teamDomain: team-foo, channel: null, color: danger, botUser: false, tokenCredentialId: slack-token, notifyCommitters: false, iconEmoji: <empty>, username: <empty>, timestamp: <empty>
ERROR: Slack notification failed. See Jenkins logs for details.
...

and jenkis logs say:

Jul 06 10:32:20 jenkins-controller jenkins[3259]: 2023-07-06 10:32:20.599+0000 [id=3008]        WARNING        j.p.slack.StandardSlackService#postToSlack: Slack post may have failed. Response: null
Jul 06 10:32:20 jenkins-controller jenkins[3259]: 2023-07-06 10:32:20.600+0000 [id=3008]        WARNING        j.p.slack.StandardSlackService#postToSlack: Response Code: 400

Any ideas would be helpful. Let me know if I can provide more info

PS without the Strict Crumb Issuer Plugin I was getting a warning and a 403. So I followed the instructions in the log file (Improved CSRF protection link), and installed it with the default configuration, Hope this wasn’t a red herring.

Jul 06 10:30:45 jenkins-controller jenkins[3259]: 2023-07-06 10:30:45.565+0000 [id=475]        INFO        o.j.p.s.StrictCrumbIssuer#validateCrumb: Invalid crumb found in the request
Jul 06 10:30:45 jenkins-controller jenkins[3259]: 2023-07-06 10:30:45.566+0000 [id=475]        WARNING        hudson.security.csrf.CrumbFilter#doFilter: Found invalid crumb 2c346e60bc7344ddbe137e316e3df8b8e7c0dadaf63dfe3aa6b769c330dcb067. If you are calling this URL with a script, please use the API Token instead. More information: https://www.jenkins.io/redirect/crumb-cannot-be-used-for-script
Jul 06 10:30:45 jenkins-controller jenkins[3259]: 2023-07-06 10:30:45.568+0000 [id=475]        WARNING        hudson.security.csrf.CrumbFilter#doFilter: No valid crumb was included in request for /ajaxExecutors by adzuna. Returning 403.

Forgot to mention I use

  • Jenkins 2.401.2
  • slack plugin Version 664.vc9a_90f8b_c24a_ (I understand this is the latest)

Clarification: I saw this Slack response code 400, message null, when using blocks · Issue #623 · jenkinsci/slack-plugin · GitHub

  • I don’t have blocks in my jenkinsfile a
  • I am using the jenkins-ci slack app

The installation instructions say that I should be using the jenkins-ci slack app, but I can also use another slack app? I am unsure

I also increased the log verbosity. I got this at the logs (but it doesn’t reveal anything to me at least)

Jul 08, 2023 10:09:16 AM FINE jenkins.plugins.slack.StandardSlackService
Posting: to null on foo:  {"attachments":[{"fallback":"Build failed - 2 in repo_foo/branch_foo (<http://jenkins-controller.example.com/job/repo_foo/job/branch_foo/2/|Open>)","color":"danger","fields":[{"short":false,"value":"Build failed - 2 in repo_foo/branch_foo (<http://jenkins-controller.example.com/job/repo_foo/job/branch_foo/2/|Open>)"}],"mrkdwn_in":["pretext","text","fields"]}],"link_names":"1","unfurl_links":"true","unfurl_media":"true","channel":"null","as_user":"true"}

Jul 08, 2023 10:09:16 AM WARNING jenkins.plugins.slack.StandardSlackService postToSlack
Slack post may have failed. Response: null

Jul 08, 2023 10:09:16 AM WARNING jenkins.plugins.slack.StandardSlackService postToSlack
Response Code: 400

Moreover, testing the slack connection through the web UI still works


and the relevant logs

Jul 08, 2023 10:14:18 AM FINE jenkins.plugins.slack.StandardSlackService
Posting: to  on foo:  {"attachments":[{"fallback":"Slack/Jenkins plugin: you're all set on http://jenkins-controller.example.com/","color":"good","fields":[{"short":false,"value":"Slack/Jenkins plugin: you're all set on http://jenkins-controller.example.com/"}],"mrkdwn_in":["pretext","text","fields"]}],"link_names":"1","unfurl_links":"true","unfurl_media":"true","channel":"","as_user":"true"}
Jul 08, 2023 10:14:18 AM FINE jenkins.plugins.slack.StandardSlackService
Posting succeeded