简体   繁体   English

Jenkins 多分支管道重建问题

[英]Jenkins Multibranch pipeline rebuild issue

I am trying to create a webhook handler for my github project for restarting the last ran Jenkins build for my PR when the PR is approved.我正在尝试为我的 github 项目创建一个 webhook 处理程序,以便在 PR 获得批准时为我的 PR 重新启动上次运行的 Jenkins 构建。

I have configured the Github webhook for my application to read the webhook payload and restart the specific Jenkins Multibranch pipeline job.我已经为我的应用程序配置了 Github webhook 以读取 webhook 有效负载并重新启动特定的 Jenkins 多分支管道作业。

I have tried restarting the last Jenkins job in my browser by running https://<jenkins_url>/job/<repo_name>/job/<branch_name>/lastBuild/rebuild which is restarting the last Jenkins build for that branch successfully.我已经尝试通过运行https://<jenkins_url>/job/<repo_name>/job/<branch_name>/lastBuild/rebuild在我的浏览器中重新启动最后一个 Jenkins 作业,它正在成功地重新启动最后一个 Z2E5433E54334C0A5CE2E 分支。

But when I tried to do the same using curl -X POST "https://<username>:<jenkins_token>@<jenkins_url>/job/<repo_name>/job/<branch_name>/lastBuild/rebuild which is not returning any error but not restarting the job though.但是当我尝试使用curl -X POST "https://<username>:<jenkins_token>@<jenkins_url>/job/<repo_name>/job/<branch_name>/lastBuild/rebuild的事情时,它没有返回任何错误但没有重新启动作业。

Can anyone suggest me how to restart/rebuild the last Jenkins build for a job using curl command.谁能建议我如何使用 curl 命令重新启动/重建最后一个 Jenkins 构建作业。

If you do not need to pass in parameters you should be able to just do a GET instead of a POST which is essentially what you're doing by visiting through the browser.如果您不需要传递参数,您应该能够只执行 GET 而不是 POST,这本质上就是您通过浏览器访问所做的事情。 Doing that may fix your issue assuming you are hitting the right URL with your curl command.假设您使用 curl 命令击中了正确的 URL ,那么这样做可能会解决您的问题。

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

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