How to Disable All Jenkins Jobs At Once - Linux Script

(Lisa Mathew) #1

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.

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

Restart jenkins for the changes to take effect.