Laravel Vapor - Test run command to do housekeeping as part of deployment process

This commit is contained in:
Dillon Ngo
2023-12-31 21:48:22 +08:00
parent 7a45d1c7e1
commit f7f4eaaafb
Vendored
+5 -20
View File
@@ -77,29 +77,14 @@ pipeline {
}
}
stage('Check Cleanup Status') {
steps {
script {
def isCleanupRunning = sh(script: 'pgrep -f "docker image prune"', returnStatus: true) == 0
currentBuild.description = isCleanupRunning ? 'Cleanup is already running' : 'Ready for cleanup'
if (isCleanupRunning) {
currentBuild.result = 'ABORTED'
error('Cleanup is already running. Aborting this build.')
}
}
}
}
stage('Cleanup') {
when {
expression {
return currentBuild.result != 'ABORTED'
}
}
steps {
script {
sh 'docker image prune -a -f'
try {
sh 'docker image prune -a -f'
} catch (Exception e) {
echo "Error during cleanup: ${e.message}"
}
}
}
}