@@ -58,11 +58,21 @@ pipeline {
5858 steps{
5959 echo " Running on node: ${ NODE_NAME} "
6060 sh ''' #! /bin/bash
61- containers=$(docker ps -aq)
61+ echo "Pruning builder"
62+ docker builder prune -f --builder container || :
63+ containers=$(docker ps -q)
6264 if [[ -n "${containers}" ]]; then
63- docker stop ${containers}
65+ BUILDX_CONTAINER_ID=$(docker ps -qf 'name=buildx_buildkit')
66+ for container in ${containers}; do
67+ if [[ "${container}" == "${BUILDX_CONTAINER_ID}" ]]; then
68+ echo "skipping buildx container in docker stop"
69+ else
70+ echo "Stopping container ${container}"
71+ docker stop ${container}
72+ fi
73+ done
6474 fi
65- docker system prune -af --volumes || : '''
75+ docker system prune -f --volumes || : '''
6676 script{
6777 env. EXIT_STATUS = ' '
6878 env. LS_RELEASE = sh(
@@ -1154,12 +1164,21 @@ EOF
11541164 }
11551165 cleanup {
11561166 sh ''' #! /bin/bash
1157- echo "Performing docker system prune!!"
1158- containers=$(docker ps -aq)
1167+ echo "Pruning builder!!"
1168+ docker builder prune -f --builder container || :
1169+ containers=$(docker ps -q)
11591170 if [[ -n "${containers}" ]]; then
1160- docker stop ${containers}
1171+ BUILDX_CONTAINER_ID=$(docker ps -qf 'name=buildx_buildkit')
1172+ for container in ${containers}; do
1173+ if [[ "${container}" == "${BUILDX_CONTAINER_ID}" ]]; then
1174+ echo "skipping buildx container in docker stop"
1175+ else
1176+ echo "Stopping container ${container}"
1177+ docker stop ${container}
1178+ fi
1179+ done
11611180 fi
1162- docker system prune -af --volumes || :
1181+ docker system prune -f --volumes || :
11631182 '''
11641183 cleanWs()
11651184 }
0 commit comments