简体   繁体   English

从 Slack 触发 Jenkins 构建

[英]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.按照下面的教程,我尝试在 Slack 中使用斜杠命令来触发 Jenkins 中的构建。 My jenkins instance which is on an EC2 is utilizing the user's API token to authenticate the POST command from slack.我在 EC2 上的 jenkins 实例正在利用用户的 API 令牌来验证来自 slack 的 POST 命令。

When I do the curl command locally, it successfully triggers the build, the command is similar to this:当我在本地执行 curl 命令时,它成功触发了构建,命令类似于:

curl -X POST http://slack:c1c54d626f6a11fbc98ed795ec8862bc@10.11.12.13:8080/job/TEST_ATOMATION_GURU_SLACK_JOB_DEMO/build 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 ).但是,当我尝试通过斜杠命令在 slack 中执行命令时,我得到:该死 - 该斜杠命令不起作用(错误消息: 403_client_error )。

Tutorial I am following: http://www.testautomationguru.com/jmeter-selenium-webdriver-how-to-trigger-automated-test-execution-from-slack/我正在关注的教程: 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我也尝试过本教程,结果相同:https ://sonnguyen.ws/how-to-trigger-a-jenkins-build-from-slack/我也看到了这个stackoverflow帖子,但没有帮助: Using Slack to开始 Jenkins 构建

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”我尝试过的事情: - 打开安全组 - 在 jenkins 中选择“允许匿名读取访问” - 在 Jenkins 中取消选择“防止跨站点请求伪造漏洞利用”

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.好消息是设置应该可以工作 - 我还有一个 Slack 斜杠命令触发 jenkins 作业,所以问题将出现在你的设置中。

I see in your curl example you are accessing jenkins on a private IP.我在您的curl示例中看到您正在访问私有 IP 上的 jenkins。 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.我会从那里开始,就像您在 Slack 斜杠命令中使用相同的私有 IP 一样,Slack 无法访问您的 Jenkins 实例。 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.如果您在 slash 命令中使用私有 IP,我建议将弹性 IP 附加到您的 EC2 实例(假设它位于公共子网等中),然后再次尝试 slash 命令,但这次是在弹性 IP 上。

you can use ngrok for the tunneling and then you should be able to trigger that.您可以将 ngrok 用于隧道,然后您应该能够触发它。

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.注意:如果使用 curl -X POST 命令手动运行,请确保您在该部分中提供的 URL 应该能够触发构建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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