Skip to content

Instantly share code, notes, and snippets.

@kubosuke
Created February 20, 2024 04:32
Show Gist options
  • Save kubosuke/c18ca90e61495b62bef5eba64730a522 to your computer and use it in GitHub Desktop.
Save kubosuke/c18ca90e61495b62bef5eba64730a522 to your computer and use it in GitHub Desktop.
for reloading config.xml after edit
import java.io.InputStream;
import java.io.FileInputStream
import java.io.File;
import javax.xml.transform.stream.StreamSource
def hudson = hudson.model.Hudson.instance;
Jenkins.instance.getAllItems(AbstractProject.class).each {job ->
if (job.fullName.startsWith("YourFolder/")) {
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