import jenkins.model.*
def matchedJobs = Jenkins.instance.items.findAll { job ->
job.name =~ /my_regex_here/
}
matchedJobs.each { job ->
println job.name
//job.delete()
}
import hudson.model.*
import jenkins.model.Jenkins
def q = Jenkins.instance.queue
q.items.findAll { it.task.name.startsWith('regexp_here') }.each { q.cancel(it.task) }
// Set how old the jobs to list should be (in days)
def numDaysBack = 700
def cutOfDate = System.currentTimeMillis() - 1000L * 60 * 60 * 24 * numDaysBack
for (job in Jenkins.instance.getAllItems(Job.class)) {
build = job.getLastSuccessfulBuild()
if (build != null && build.getTimeInMillis() < cutOfDate) {
println job.getFullName()
}
}
import jenkins.model.*
def matchedJobs = Jenkins.instance.items.findAll { job ->
job.name =~ /ignition_msgs.*windows/
}
matchedJobs.each { job ->
println job.name
if (job.building) {
println "Skipping job $job.name, currently building"
} else {
println "Wiping out workspace of $job.name"
job.doDoWipeOutWorkspace()
}
}
import jenkins.model.*
def matchedJobs = Jenkins.instance.items.findAll { job ->
job.name =~ /-gazebo11.*bionic.*/
}
matchedJobs.each { job ->
new_name = job.name.replace('bionic','focal')
if (jenkins.model.Jenkins.instance.getItem(new_name) != null) {
println " = Job " + new_name + " exists!"
} else {
println " * " + job.name + " ----> " + new_name
// job.renameTo(new_name)
}
}