Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HUDSON: How to stop hudson job from command line?

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.

like image 684
girishs Avatar asked Apr 25 '11 10:04

girishs


People also ask

How do I stop Jenkins from command line?

#stop_build(job_name, build_number = 0) ⇒ Object (also: #stop, #abort) Stops a running build of a job This method will stop the current/most recent build if no build number is specified. Save this answer. Show activity on this post. This option assumes you have access to the Jenkins installation.

How to authenticate Jenkins CLI?

Authentication. Whichever user used for authentication with the Jenkins controller must have the Overall/Read permission in order to access the CLI. The user may require additional permissions depending on the commands executed. Authentication in SSH mode relies on SSH-based public/private key authentication.


1 Answers

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.

like image 72
aflat Avatar answered Sep 22 '22 07:09

aflat