Skip to content

Instantly share code, notes, and snippets.

@matthiasbaldi
Last active September 20, 2016 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthiasbaldi/a01e4ce52e46c93a769c819c1951fa84 to your computer and use it in GitHub Desktop.
Save matthiasbaldi/a01e4ce52e46c93a769c819c1951fa84 to your computer and use it in GitHub Desktop.
Reload Jenkins Job
// inspired by https://github.com/jenkinsci/jenkins-scripts/blob/master/scriptler/reloadJobConfig.groovy
// by Matthias Baldi @2016
import java.io.File;
import java.io.InputStream;
import java.io.FileInputStream
import javax.xml.transform.stream.StreamSource
// load job and configuration
def job = Jenkins.instance.getItemByFullName("PA-ISA-APIs-admin")
File file = job.getConfigFile().getFile()
// refresh job configuration
InputStream is = new FileInputStream(file);
job.updateByXml(new StreamSource(is));
job.save();
println("Configuration of Job " + job.name + " refreshed.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment