Change Jenkins section to CI/CD
CI/CD will include Jenkins and other CI/CD systems. In addition, added a couple of questions on various topics.
This commit is contained in:
16
exercises/cicd/solutions/remove_builds_solution.groovy
Normal file
16
exercises/cicd/solutions/remove_builds_solution.groovy
Normal file
@@ -0,0 +1,16 @@
|
||||
def removeOldBuilds(buildDirectory, days = 14) {
|
||||
|
||||
def wp = new File("${buildDirectory}")
|
||||
def currentTime = new Date()
|
||||
def backTime = currentTime - days
|
||||
|
||||
wp.list().each { fileName ->
|
||||
folder = new File("${buildDirectory}/${fileName}")
|
||||
if (folder.isDirectory()) {
|
||||
def timeStamp = new Date(folder.lastModified())
|
||||
if (timeStamp.before(backTime)) {
|
||||
folder.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
6
exercises/cicd/solutions/remove_jobs_solution.groovy
Normal file
6
exercises/cicd/solutions/remove_jobs_solution.groovy
Normal file
@@ -0,0 +1,6 @@
|
||||
def jobs = Jenkins.instance.items.findAll { job -> job.name =~ /"test"/ }
|
||||
|
||||
jobs.each { job ->
|
||||
println job.name
|
||||
//job.delete()
|
||||
}
|
Reference in New Issue
Block a user