From f470698c2c10c2382080fab34f83088450fabdd6 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Wed, 18 Sep 2019 21:47:58 +0000 Subject: [PATCH] Jenkinsfile: ensure all containers are cleaned up By convention, containers spawned by jenkins jobs have the name: docker-pr${BUILD_NUMBER} That works fine for jobs with a single container. This commit cleans up when multiple containers are spawned with the convention that their names share the same "docker-pr${BUILD_NUMBER}-" prefix. Signed-off-by: Tibor Vass --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index f04d90deec..32c0307d7d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -701,6 +701,8 @@ pipeline { sh ''' echo "Ensuring container killed." docker rm -vf docker-pr$BUILD_NUMBER || true + cids=$(docker ps -aq -f name=docker-pr${BUILD_NUMBER}-*) + [ -n "$cids" ] && docker rm -vf $cids || true ''' sh '''