简体   繁体   中英

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.

I have configured the Github webhook for my application to read the webhook payload and restart the specific Jenkins Multibranch pipeline job.

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.

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.

Can anyone suggest me how to restart/rebuild the last Jenkins build for a job using curl command.

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. Doing that may fix your issue assuming you are hitting the right URL with your curl 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