[ACCEPTED]-hudson CI: how to delete all jobs?-hudson

Accepted answer
Score: 46

The easiest way, IMHO, would be to use script. Go 4 to http://your.hudson.url/script/

Delete jobs by running:

for(j in hudson.model.Hudson.theInstance.getProjects()) {

And this way gives 3 you an option to easily use condition to 2 filter out jobs to delete.


Current versions 1 (2.x):

for(j in jenkins.model.Jenkins.theInstance.getAllItems()) {

Older versions:

for(j in jenkins.model.Jenkins.getInstance().getProjects()) {
Score: 15

Just delete the job directories:

cd $HUDSON_HOME/jobs
rm -rf <JOB_NAME>

See: Administering Hudson


Score: 7

You can programmatically use the XML api (or use 5 the JSON flavor if you prefer that):



    <!-- etc -->

Now 4 iterate over the job names and do a post 3 request to


(You can do this with any programming 2 language you like that supports XML and 1 HTTP)

Score: 3

I had similar manageability problems with 24 a Hudson instance that was running 500+ build 23 jobs - it was impractical to manually maintain 22 that many jobs using the gui. However, you 21 can provision jobs in Hudson remotely and 20 programatically by using the CLI - which 19 is supplied as a jar file [http://wiki.hudson-ci.org/display/HUDSON/Hudson+CLI].

The command to delete a job would be something like:
**java -jar hudson-cli.jar -s http://host:port/ delete-job jobname**

And the rest of the commands you will need are here:
**java -jar hudson-cli.jar -s http://host:port/** help

I wrapped the 18 cli in python and created an XML file from 17 which to hold the build configuration - then 16 I could use this to manipulate my running 15 instances of Hudson. This also provided 14 the ability to 'reset' the CI instance back 13 to a known configuration - handy if you 12 suspect build failures were caused by manual 11 changes in the UI or if you are using a 10 different CI server for each environment 9 you deploy to (ie dev, test, prod) and need 8 to provision a new one.

This has also got 7 me out of a few binds when badly written 6 plugins have mangled Hudson's own XML and 5 I've needed to rebuild my instances. Hudson 4 is also I/O bound and for really loaded 3 instances it is often faster to boot Hudson 2 from scratch and populate it's configuration 1 this way.

More Related questions