HUDSON: How to stop hudson job from command line?

girishs picture girishs · Apr 25, 2011 · Viewed 9.7k times · Source

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.

Answer

aflat picture aflat · Apr 25, 2011

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.