@@ -56,11 +56,21 @@ pipeline {
56
56
steps{
57
57
echo " Running on node: ${ NODE_NAME} "
58
58
sh ''' #! /bin/bash
59
- containers=$(docker ps -aq)
59
+ echo "Pruning builder"
60
+ docker builder prune -f --builder container || :
61
+ containers=$(docker ps -q)
60
62
if [[ -n "${containers}" ]]; then
61
- docker stop ${containers}
63
+ BUILDX_CONTAINER_ID=$(docker ps -qf 'name=buildx_buildkit')
64
+ for container in ${containers}; do
65
+ if [[ "${container}" == "${BUILDX_CONTAINER_ID}" ]]; then
66
+ echo "skipping buildx container in docker stop"
67
+ else
68
+ echo "Stopping container ${container}"
69
+ docker stop ${container}
70
+ fi
71
+ done
62
72
fi
63
- docker system prune -af --volumes || : '''
73
+ docker system prune -f --volumes || : '''
64
74
script{
65
75
env. EXIT_STATUS = ' '
66
76
env. LS_RELEASE = sh(
@@ -1152,12 +1162,21 @@ EOF
1152
1162
}
1153
1163
cleanup {
1154
1164
sh ''' #! /bin/bash
1155
- echo "Performing docker system prune!!"
1156
- containers=$(docker ps -aq)
1165
+ echo "Pruning builder!!"
1166
+ docker builder prune -f --builder container || :
1167
+ containers=$(docker ps -q)
1157
1168
if [[ -n "${containers}" ]]; then
1158
- docker stop ${containers}
1169
+ BUILDX_CONTAINER_ID=$(docker ps -qf 'name=buildx_buildkit')
1170
+ for container in ${containers}; do
1171
+ if [[ "${container}" == "${BUILDX_CONTAINER_ID}" ]]; then
1172
+ echo "skipping buildx container in docker stop"
1173
+ else
1174
+ echo "Stopping container ${container}"
1175
+ docker stop ${container}
1176
+ fi
1177
+ done
1159
1178
fi
1160
- docker system prune -af --volumes || :
1179
+ docker system prune -f --volumes || :
1161
1180
'''
1162
1181
cleanWs()
1163
1182
}
0 commit comments