Skip to content

Instantly share code, notes, and snippets.

@scrain
Created September 21, 2021 17:35
Show Gist options
  • Save scrain/1e0cf8341d01362647854dc46c88b191 to your computer and use it in GitHub Desktop.
Save scrain/1e0cf8341d01362647854dc46c88b191 to your computer and use it in GitHub Desktop.
Reloads the config for individual jobs
import java.io.InputStream;
import java.io.FileInputStream
import java.io.File;
import javax.xml.transform.stream.StreamSource
def hudson = hudson.model.Hudson.instance;
for(job in Jenkins.instance.getAllItems(Job.class)) {
if (job.name.contains("somename")) {
println job.name
def configXMLFile = job.getConfigFile();
def file = configXMLFile.getFile();
InputStream is = new FileInputStream(file);
job.updateByXml(new StreamSource(is));
job.save();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment