Skip to content

Commit 504afa4

Browse files
committed
chore(jenkins): clean up custom workspace directories
1 parent 638d011 commit 504afa4

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

.jenkins.groovy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,20 @@ Check console output at "<a href="${env.BUILD_URL}">${env.JOB_NAME} [${env.BRANC
201201
// Cleanup the build directory if the build was successful
202202
// (in this case we probably don't have to do any post-build analysis)
203203
cleanBeforeCheckout()
204+
stage('Prune old workspaces') {
205+
when {
206+
expression { MATRIX_JDK == latestSupportedJDK }
207+
}
208+
steps {
209+
sh '''
210+
set -eu
211+
base_dir="workspace/${JOB_NAME}/MatrixCheckout"
212+
if [ -d "$base_dir" ]; then
213+
find "$base_dir" -mindepth 1 -maxdepth 1 -type d -mtime +30 -exec rm -rf {} +
214+
fi
215+
'''
216+
}
217+
}
204218
script {
205219
if (deployableBranch
206220
&& (currentBuild.previousBuild != null) && (currentBuild.previousBuild.result != 'SUCCESS')) {

0 commit comments

Comments
 (0)