Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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

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.

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!

This can be done using jenkins Console. It runs groovy script and do almost anything.

Following script iterates through all projects. Check if it has TimerTrigger.(One can extend this check of other triggers as well)

import hudson.model.Hudson
import hudson.model.Project
import hudson.triggers.TimerTrigger
import hudson.triggers.Trigger
import hudson.triggers.TriggerDescriptor

//All the projects on which we can apply the getBuilders method
def allProjects = Hudson.instance.items.findAll { it instanceof Project }
def projectsToWorkOn = [];
allProjects.each { Project project ->
    Map<TriggerDescriptor, Trigger> triggers =
            project.getTriggers();
    triggers.each { trigger ->

        if (trigger.value instanceof TimerTrigger) {
            projectsToWorkOn.push(project)


        }

    }
}


projectsToWorkOn
        .each { Project project ->

    project.disable();
    project.save()
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top