Skip to content

Instantly share code, notes, and snippets.

@petersellars
Last active August 29, 2015 14:17
Show Gist options
  • Save petersellars/34178baafdadbef7dcd4 to your computer and use it in GitHub Desktop.
Save petersellars/34178baafdadbef7dcd4 to your computer and use it in GitHub Desktop.
Jenkins Groovy Scripts: Update Groovy from 2.2.1/Default to Groovy 2.3 builders
import jenkins.model.*
for(item in Jenkins.instance.items) {
if (!(item instanceof com.cloudbees.plugins.flow.BuildFlow)
&& !(item instanceof hudson.maven.MavenModuleSet)
&& !(item instanceof org.jenkinsci.plugins.workflow.job.WorkflowJob)) {
for (builder in item.builders) {
if(builder instanceof hudson.plugins.gradle.Gradle) {
println(item.name)
println(builder)
println(builder.gradleName)
String gradleName = builder.gradleName
if (gradleName == "(Default)" || gradleName == "Gradle-2.2.1") {
println("Need to update!!")
println(builder.properties)
hudson.plugins.gradle.Gradle newGradle = new hudson.plugins.gradle.Gradle(
builder.properties.description,
builder.properties.switches,
builder.properties.tasks,
builder.properties.rootBuildScriptDir,
builder.properties.buildFile,
"Gradle-2.3",
builder.properties.useWrapper,
builder.properties.makeExecutable,
builder.properties.fromRootBuildScriptDir,
builder.properties.useWorkspaceAsHome)
println(newGradle.properties)
println(item.buildersList)
item.buildersList.replace(newGradle)
println(item.buildersList)
}
println('\n')
}
}
}
}
@petersellars
Copy link
Author

Need to make this more generic - too specific at this time but does the job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment