def f_delete_month_old_jobs(job) {
println "delete? " + deleter
println "THIS IS ACTIVE JOB. WE ARE DELETING ALL BUILDS, OLDER THAN 30 DAYS."
//def recent = job.builds
def deleted = 0
def saved = 0
for (build in job.builds) {
println build
if (!(build == job.getLastSuccessfulBuild()) && !build.isBuilding() && !build.isKeepLog() && !(build.getTime() > now_minus_month)) {
if (deleter) {
println "DELETING: " + build + " WITH BUILD DATE = " + build.getTime()
build.delete()
println "deleted!"
} else {
println "just reading..."
println "READY TO DELETE: " + build + " WITH BUILD DATE = " + build.getTime()
}
deleted++
global_deleted++
} else {
println "---> IGNORING BUILD " + build + " WITH BUILD DATE = " + build.getTime() + " is marked to be skipped, is building, or marked to keep"
saved++
}
}
println "DELETED " + deleted + ", SAVED " + saved
}