Skip to content

Instantly share code, notes, and snippets.

@utopius
Forked from retronym/script.groovy
Created June 7, 2016 07:15
Show Gist options
  • Save utopius/1e50a4fab24420bc613af8f290540c94 to your computer and use it in GitHub Desktop.
Save utopius/1e50a4fab24420bc613af8f290540c94 to your computer and use it in GitHub Desktop.
jenkins job cloning
def projects = [
"scala-nightly-checkinit",
"scala-nightly-main",
"scala-nightly-rangepos",
"scala-nightly-windows"
]
inst = jenkins.model.Jenkins.instance;
def oldVersion = "2.10.x"
def newVersion = "2.11.x"
for (p in projects) {
def templateProject = inst.getItem(p + "-" + oldVersion);
def newProject = inst.copy(templateProject, p + "-" + newVersion);
println("created " + newProject);
def branchParam = newProject.actions.find{ it instanceof ParametersDefinitionProperty }?.getParameterDefinition("branch");
if (branchParam != null) {
branchParam.setDefaultValue(newVersion) ;
println("found and updated branch parameter");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment