How to Disable All Jenkins Jobs At Once - Linux Script

I do not advise you to run this on production. You can first test it on a test instance to see how it acts on your Jenkins instance.

All jenkins jobs are saved in the form of config.xml in the jenkins home directory. For example, in /var/lib/jenkins

IN every job XML, you have a parameter <disabled> under <canRoam>. So all you need to do it replace the disabled parameter to true under canRoad. You can do that using the following Linux bash script. Make user you run the script from the jobs directory which is present in the jenkins home directory.

#!/bin/bash
for job in `find . | grep -i config.xml`
do
sudo sed -i '/<canRoam>false<\/canRoam>/{n;s/.*/<disabled>true<\/disabled>/}' $job
done

Restart jenkins for the changes to take effect.

Hi,

messing with the config.xml files? Really? Followed by a restart?

Better open the Groovy Script console and copy/paste one of the Groovy scripts found if you search Google for “Jenkins Groovy dsable all jobs”. Or simply use the Configuration Slicer if you already have it installed. No need for a restart.