HUDSON: How to stop hudson job from command line?

前端 未结 2 1561
小鲜肉
小鲜肉 2020-12-16 04:10

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/JOBN

相关标签:
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.

    0 讨论(0)
  • 2020-12-16 05:00

    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.

    0 讨论(0)
提交回复
热议问题