Search code examples
jenkinsslack

Trigger Jenkins job via Slack command - 403_client_error


I'm trying to do a pretty simple thing I believe - trigger a Jenkins job from a slash command in slack. I want to type /dump in slack and that should trigger particular jenkins job. I'm using Slack Slash command to achieve this and the setup is very simple - type command, type URL, select POST/GET method.

I tried two methods - first was to use Build Authorization Token Root Plugin following this tutorial - in this case I configured Slack slash command to make GET request on the URL: http://jenkins_url:8080/job/db-dump-setup/build?token=MY_TOKEN - If I put the URL to my browser, the job gets triggered, if I run the /dump command, slack responds with:

slackbot [3:41 PM]
Darn - that slash command didn't work (error message: `403_client_error`). Manage the command at text.

The second approach I tried was following this tutorial. In this case I created new user in Jenkins and got API token. When running this command from my terminal: curl -X POST http://USER:TOKEN@slack_url:8080/job/db-dump-setup/build, the job gets again triggered, however when configuring the Slack slash command with the same URL and making POST request, I get the same error: 403_client_error

I tried to google this specific error but didn't find anything useful, also there are no more details for the error or any logs which could help me to troubleshoot this further.

Anyone run into something similar and knows how could I get this resolved?


Solution

  • I was able to resolve this so answering my own question in a case someone else runs into this. In order to make the first case work (Using the GET request), I had to enable the "Allow anonymous read access" in Jenkins, in Manage Jenkins -> Configure Global Security as per the screenshot below.

    enter image description here