HUDSON: How to stop hudson job from command line?

家住魔仙堡 提交于 2019-12-18 03:37:07

问题


I need to forcefully stop a Hudson build running in remote server. Is there a command/API to do that?

for ex: to trigger a new build we can do :- HUDSON_URL/job/JOBNAME/build

looking for similar API to stop the build.


回答1:


You should be able to make a http request to

http://HUDSON_URL/job/JOBNAME/BUILDNUMBER/stop

and you can do a xpath request to get the build number

http://HUDSON_URL/job/JOBNAME/api/xml?xpath=//lastBuild/number/text()

There may be a way to put in latestBuild or lastBuild instead of BUILDNUMBER, but if not, you can just use 2 http gets.




回答2:


From the above answer (upvoted), @girishs' comment, and some work of my own, in a Windows environment (Linux could probably use wget instead of curl, haven't tested):

curl --request POST -u <USER>:<PASS> "%JENKINS_URL%/job/%JOB_NAME%/lastBuild/stop"

...which stops the most recent build without any future config editing. All you need is your user/pass combo.



来源:https://stackoverflow.com/questions/5777538/hudson-how-to-stop-hudson-job-from-command-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!