Created
September 21, 2021 17:35
-
-
Save scrain/1e0cf8341d01362647854dc46c88b191 to your computer and use it in GitHub Desktop.
Reloads the config for individual jobs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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