简体   繁体   中英

Triggering Jenkins builds from Slack

By following the tutorial below I am attempting to use slash commands in Slack to trigger a build in Jenkins. My jenkins instance which is on an EC2 is utilizing the user's API token to authenticate the POST command from slack.

When I do the curl command locally, it successfully triggers the build, the command is similar to this:

curl -X POST http://slack:c1c54d626f6a11fbc98ed795ec8862bc@10.11.12.13:8080/job/TEST_ATOMATION_GURU_SLACK_JOB_DEMO/build

However when I try to execute the command in slack via a slash command I get: Darn - that slash command didn't work (error message: 403_client_error ).

Tutorial I am following: http://www.testautomationguru.com/jmeter-selenium-webdriver-how-to-trigger-automated-test-execution-from-slack/

I have also tried this tutorial with the same result:https://sonnguyen.ws/how-to-trigger-a-jenkins-build-from-slack/ I also saw this stackoverflow post but it did not help: Using Slack to start Jenkins builds

Things I have tried: - Opening up the security groups - In jenkins selecting “Allow anonymous read access” - In Jenkins deselecting “Prevent Cross Site Request Forgery exploits”

Any help or guidance would be much appreciated.

enter image description here

The good news is that the setup should work - I also have a Slack slash command triggering a jenkins job, so the issue will be somewhere in your setup.

I see in your curl example you are accessing jenkins on a private IP. I would start there as if you are using the same private IP in the Slack slash command, there is no way Slack would be able to access your Jenkins instance. If you are using private IP in the slash command, I would recommend attaching an Elastic IP to your EC2 instance (assuming it lives in public subnet etc) and then try again the slash command but on the Elastic IP this time.

you can use ngrok for the tunneling and then you should be able to trigger that.

note: Ensure that the URL you are giving in the section should be able to trigger the build if run manually using the curl -X POST command.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM