Is there a way in Jenkins (Hudson) to disable a job from another job?
Basically we have a build environment that does the standard building/testing. We also use the same Jenkins instance to do some other stuff like install new versions of our product automatically (which is needed for some of the automated tests). When we are running some of the "extra" jobs, we want to disable the "standard" jobs temporarily (and then automatically enable them later).
Ideally there would be some extra build step on a job to say "Disable XYZ job". Or if there is a way through ANT or something to tell Jenkins to disable a job, that would work too.
Update: It looks like there are a couple plugins that will prevent two jobs from running at the same time, but I really need to:
In order to prevent Jenkins from executing any jobs, you need to put it in "quiet down" mode when it starts up. There are two ways you can do this. You can install and use the Quiet Start plugin. This will give you a UI option to restart Jenkins and have it be in "quiet down" mode when it starts up.
Pipeline jobs can be stopped by sending an HTTP POST request to URL endpoints of a build. BUILD ID URL/stop - aborts a Pipeline. BUILD ID URL/term - forcibly terminates a build (should only be used if stop does not work). BUILD ID URL/kill - hard kill a pipeline.
disabled(boolean shouldDisable = true) Disables the job, so that no new builds will be executed until the project is re-enabled.
It's possible to do this using the Job DSL Plugin, without specifying credentials.
The DSL script to use would be:
job("jobname"){
using("jobname")
disabled(true)
}
pipelineJob
instead of job
."jobname"
needs to include folders, using the Jenkins root as reference.disabled(false)
.Recent version of Jenkins (2 and over) change the method name.
Just replace disable()
with setDisabled(boolean)
Found that this worked for me:Jenkins.instance.getItem("jobname").setDisabled(false)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With