This file contains hidden or 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")) { |
This file contains hidden or 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
| String oldLabel = 'foo' | |
| String newLabel = 'bar' | |
| boolean dryRun = true | |
| for (item in Jenkins.instance.getAllItems(Job.class).findAll{it.hasProperty('assignedLabel')}) { | |
| if (oldLabel == item.assignedLabel.toString()) { | |
| println "${item.name}: label being updated from '${oldLabel}' to '${newLabel}'" | |
| if (!dryRun) { | |
| item.setAssignedLabel(new hudson.model.labels.LabelAtom(newLabel)) | |
| } |
This file contains hidden or 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
| BUILD_STRING = "ERROR" | |
| for (job in Jenkins.instance.getAllItems(Job.class)) { | |
| if (job.builds[0]?.log?.contains(BUILD_STRING)) { | |
| println "${job.name}: ${job.builds[0].id}" | |
| } | |
| } |
This file contains hidden or 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
| String oldJdkName = "JDK 1.7.0_80" | |
| String newJdkName = "JDK 1.8.202" | |
| boolean dryRun = true | |
| Set jdks = new HashSet() | |
| def newJdk = Jenkins.instance.getJDK(newJdkName) | |
| assert newJdk, "unable to find a configured jdk named ${newJdkName}" | |
| println "reconfiguring all jobs using ${oldJdkName} to use jdk '${newJdkName}'" |
This file contains hidden or 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
| def allJobs = hudson.model.Hudson.getInstance().allItems.findAll { it instanceof hudson.model.AbstractProject } | |
| allJobs.findAll{ | |
| it.someWorkspace?.list().find{ f -> | |
| ( !f.isDirectory() && f.name.endsWith('.gradle') && f.readToString().contains('some string') ) | |
| } | |
| }.each { | |
| println "${it.name}\t${it.absoluteUrl}" | |
| } |
This file contains hidden or 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
| for d in ./*/ ; do (cd "$d" && echo "$d" && somecommand ); done |
This file contains hidden or 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
| def jobsWithJdkSupport = Jenkins.instance.getAllItems(Job.class).findAll{it.hasProperty('JDK')} | |
| def jdksInUse = jobsWithJdkSupport.collect{it.JDK?.name}.unique() | |
| println "jdks in use: ${jdksInUse}\n" | |
| jdksInUse.each{ jdk -> | |
| println "jdk '${jdk}'" | |
| jobsWithJdkSupport.findAll{ it.JDK?.name == jdk }.each { job -> | |
| println "\t${job.name}" |
This file contains hidden or 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 hudson.model.* | |
| String newJdkName = "JDK 1.7.0_80" | |
| boolean dryRun = true | |
| def h = Hudson.getInstance() | |
| Set jdks = new HashSet() | |
| def newJdk = h.getJDK(newJdkName) | |
| assert newJdk, "unable to find a configured jdk named ${newJdkName}" |
This file contains hidden or 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
| assemble.dependsOn assembleWar | |
| assemble.outputs.files assembleWar.outputs.files |