Created
February 9, 2012 19:32
-
-
Save abayer/1782288 to your computer and use it in GitHub Desktop.
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 jenkins.model.* | |
import hudson.util.DescribableList | |
import hudson.tasks.Builder | |
import hudson.model.Descriptor | |
import hudson.tasks.Maven | |
def newMavenName = "Maven 3.0" | |
def jobs = Jenkins.instance.items | |
jobs.each { j -> | |
if (j instanceof hudson.model.FreeStyleProject || j instanceof hudson.matrix.MatrixProject) { | |
DescribableList<Builder,Descriptor<Builder>> newBuilders = new DescribableList<Builder,Descriptor<Builder>>(j) | |
def sawMaven = false | |
j.builders.each { b -> | |
if (b instanceof hudson.tasks.Maven) { | |
if (!b.mavenName.equals(newMavenName)) { | |
sawMaven = true | |
println "${j.name} has a build step with old mavenName ${b.mavenName}. Replacing with ${newMavenName}." | |
Maven newStep = new Maven(b.getTargets(), newMavenName, b.pom, b.@properties, b.jvmOptions, b.usesPrivateRepository()) | |
newBuilders.add(newStep) | |
} else { | |
newBuilders.add(b) | |
} | |
} else { | |
newBuilders.add(b) | |
} | |
} | |
if (sawMaven) { | |
j.builders.replaceBy(newBuilders) | |
} | |
} | |
else if (j instanceof hudson.maven.MavenModuleSet) { | |
if (!j.mavenName.equals(newMavenName)) { | |
println "${j.name} is a maven build with old mavenName ${j.mavenName}. Replacing with ${newMavenName}." | |
j.setMaven(newMavenName) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment