Skip to content

Commit

Permalink
Merge pull request #321 from linuxserver/monthly-cleanup
Browse files Browse the repository at this point in the history
Prune but don't remove buildx container
  • Loading branch information
aptalca authored Dec 16, 2024
2 parents c173943 + a591261 commit 03fb2a1
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions roles/generate-jenkins/templates/Jenkinsfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,21 @@ pipeline {
steps{
echo "Running on node: ${NODE_NAME}"
sh '''#! /bin/bash
containers=$(docker ps -aq)
echo "Pruning builder"
docker builder prune -f --builder container || :
containers=$(docker ps -q)
if [[ -n "${containers}" ]]; then
docker stop ${containers}
BUILDX_CONTAINER_ID=$(docker ps -qf 'name=buildx_buildkit')
for container in ${containers}; do
if [[ "${container}" == "${BUILDX_CONTAINER_ID}" ]]; then
echo "skipping buildx container in docker stop"
else
echo "Stopping container ${container}"
docker stop ${container}
fi
done
fi
docker system prune -af --volumes || : '''
docker system prune -f --volumes || : '''
script{
env.EXIT_STATUS = ''
env.LS_RELEASE = sh(
Expand Down Expand Up @@ -1447,12 +1457,21 @@ EOF
}
cleanup {
sh '''#! /bin/bash
echo "Performing docker system prune!!"
containers=$(docker ps -aq)
echo "Pruning builder!!"
docker builder prune -f --builder container || :
containers=$(docker ps -q)
if [[ -n "${containers}" ]]; then
docker stop ${containers}
BUILDX_CONTAINER_ID=$(docker ps -qf 'name=buildx_buildkit')
for container in ${containers}; do
if [[ "${container}" == "${BUILDX_CONTAINER_ID}" ]]; then
echo "skipping buildx container in docker stop"
else
echo "Stopping container ${container}"
docker stop ${container}
fi
done
fi
docker system prune -af --volumes || :
docker system prune -f --volumes || :
'''
cleanWs()
}
Expand Down

0 comments on commit 03fb2a1

Please sign in to comment.