Last active
September 16, 2019 12:00
-
-
Save jbasila/cda06c91e22b7e18311ff96b9070d5c2 to your computer and use it in GitHub Desktop.
Jenkins: Delete older builds
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
// run this on the master: | |
// $ du -sk MAG-* |sort -rn|head -20 | while read _line ; do _ar=( ${_line} ); echo -n "\"$(cat ${_ar[1]}/name-utf8.txt)\", "; done ;echo "" | |
_array=[ ] | |
_array.each { | |
JOB_NAME="Magnifier/${it}" | |
KEEP_LAST_NUM_OF_BUILDS=2 | |
Jenkins.instance.getItemByFullName("${JOB_NAME}").builds.findAll { true }.each { | |
if (KEEP_LAST_NUM_OF_BUILDS) { | |
KEEP_LAST_NUM_OF_BUILDS-- | |
} else { | |
it.delete() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment