From 7a45d1c7e1351e6cb813e6a478404df834d5cd90 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Sun, 31 Dec 2023 21:28:11 +0800 Subject: [PATCH] Laravel Vapor - Test run command to do housekeeping as part of deployment process --- Jenkinsfile | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 623be806..330f47ee 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -77,7 +77,26 @@ 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'