[api] Jenkinsfile.pjt

- 삭제정책 추가
This commit is contained in:
2026-02-04 16:06:01 +09:00
parent 8d38ae1a9c
commit 06faa99267
-31
View File
@@ -217,37 +217,6 @@ pipeline {
echo "[0] Repo: $REPO"
echo "[1] Collect running image refs (repo:tag) to protect"
RUNNING_REFS=$(docker ps --format "{{.Image}}" | grep -E "^${REPO}:" | sort -u || true)
if [ -n "$RUNNING_REFS" ]; then
echo "Running refs (protected):"
echo "$RUNNING_REFS" | sed "s/^/ - /"
else
echo "No running refs found for $REPO (check if you run by digest or different name)"
fi
echo "[2] Remove stopped containers (so they dont hold images)"
docker container prune -f
echo "[3] List all local refs for repo"
ALL_REFS=$(docker images "$REPO" --format "{{.Repository}}:{{.Tag}}" | grep -v "<none>" | sort -u || true)
echo "[4] Remove repo images except protected running refs"
for REF in $ALL_REFS; do
if [ -n "$RUNNING_REFS" ] && echo "$RUNNING_REFS" | grep -qx "$REF"; then
echo "Skip running: $REF"
continue
fi
echo "Removing: $REF"
docker rmi -f "$REF" || true
done
echo "[5] Remove dangling images"
docker image prune -f
echo "[6] Remove unused volumes"
docker volume prune -f
'
'''
}