views:

716

answers:

5

We have a large Hudson set up with many scheduled builds running all the time. Currently I'm trying to get one build to work properly, but I have to occasionally wait when a scheduled build enters the queue. Is there a way to disable all the scheduled builds so I can concentrate on my troublesome build, without adjusting the "cron" settings of each individual build?

A: 

I don't see a direct way to do it, but you could write something that updates the config.xml for all jobs.

In each job's directory in hudson, there's a config.xml. The <project> has an element called disabled that you could update to true, thereby disabling that build.

Not ideal, but once you have the script to walk a directory and change the value of disabled, you can always use it.

Mikezx6r
+4  A: 

Tell it to prepare to shut down.


Edit from OP (banjollity)
It's not perfect, but I think this is a reasonable "few mouse clicks solution with a default install" kind of solution, hence the accepted answer.

  1. Queue up a job
  2. Tell Hudson to prepare to shut down. This prevents other jobs being run in the meantime.
  3. Diagnose faults with my job, commit new code that might fix it. (I love my job).
  4. Cancel Hudson shut down.
  5. Goto step 1.
Thorbjørn Ravn Andersen
So far so good with this. It has stopped the other jobs, but has still let me queue up the one I want.
banjollity
Nice--I didn't know you could do that. +1
Michael Haren
+3  A: 

The 'configuration slicing' plugin I contributed allows you to modify the cron settings of many jobs simultaneously. This should allow you to make the bulk changes you want.

Michael Donohue
A: 

Expanding upon Mikezx6r's suggestion, I just came up with a quick method to disable all builds matching a certain string:

[user@server jobs] $ for i in *build_name*; do sed -i s/"disabled>false"/"disabled>true/" $i/config.xml; done

You could also iterate through specific build names in the "for" loop:

[user@server jobs] $ for i in build1 build2 build3; do sed -i s/"disabled>false"/"disabled>true/" $i/config.xml; done

You can test it first to see what it will do by putting an "echo" before sed:

[user@server jobs] $ for i in build1 build2 build3; do echo sed -i s/"disabled>false"/"disabled>true/" $i/config.xml; done

Conversely, you can re-enable all matching jobs by switching around the sed script:

[user@server jobs] $ for i in build1 build2 build3; do sed -i s/"disabled>true"/"disabled>false/" $i/config.xml; done

Justin Foreman
A: 

A search for something similar brought me to this question, and I realized there's another benefit of Michael Donohue's answer (and the plugin he contributed).

With "Configuration Slicing," it's easy to disable a subset of your jobs all at once. That's exactly what I needed to temporarily disable 7 of 8 related jobs so I could work on the 8th. Thanks Michael!

Paul Karlin