Issue
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:
- Run job A which disables job 1
- Do some stuff outside of Jenkins based on output of job A
- Run job B which which enable job 1 again
Solution
I found one possible approach using the jenkins-cli (command-line interface). I added this build step (for me it was a Windows batch command, though I may make it a script or something more elegant):
java -jar C:\my\jenkins\path\jenkins-cli.jar -s %JENKINS_URL% disable-job "Job 1"
I haven't looked into how to get the path to Jenkins, but that should not be too hard.
Here is some information on the CLI. You can also go to http://your-jenkins:8080/cli for some of the available commands.
Answered By - Matt N
Answer Checked By - Gilberto Lyons (JavaFixing Admin)