@@ -58,11 +58,21 @@ pipeline {
58
58
steps{
59
59
echo " Running on node: ${ NODE_NAME} "
60
60
sh ''' #! /bin/bash
61
- containers=$(docker ps -aq)
61
+ echo "Pruning builder"
62
+ docker builder prune -f --builder container || :
63
+ containers=$(docker ps -q)
62
64
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
64
74
fi
65
- docker system prune -af --volumes || : '''
75
+ docker system prune -f --volumes || : '''
66
76
script{
67
77
env. EXIT_STATUS = ' '
68
78
env. LS_RELEASE = sh(
@@ -1092,12 +1102,21 @@ EOF
1092
1102
}
1093
1103
cleanup {
1094
1104
sh ''' #! /bin/bash
1095
- echo "Performing docker system prune!!"
1096
- containers=$(docker ps -aq)
1105
+ echo "Pruning builder!!"
1106
+ docker builder prune -f --builder container || :
1107
+ containers=$(docker ps -q)
1097
1108
if [[ -n "${containers}" ]]; then
1098
- docker stop ${containers}
1109
+ BUILDX_CONTAINER_ID=$(docker ps -qf 'name=buildx_buildkit')
1110
+ for container in ${containers}; do
1111
+ if [[ "${container}" == "${BUILDX_CONTAINER_ID}" ]]; then
1112
+ echo "skipping buildx container in docker stop"
1113
+ else
1114
+ echo "Stopping container ${container}"
1115
+ docker stop ${container}
1116
+ fi
1117
+ done
1099
1118
fi
1100
- docker system prune -af --volumes || :
1119
+ docker system prune -f --volumes || :
1101
1120
'''
1102
1121
cleanWs()
1103
1122
}
0 commit comments