From f721101722732462ee16f7a730c1707261428986 Mon Sep 17 00:00:00 2001 From: continuist Date: Sat, 28 Jun 2025 14:19:24 -0400 Subject: [PATCH] Clean up the test repository from the registry at the end of the test step --- CI_CD_PIPELINE_SETUP_GUIDE.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/CI_CD_PIPELINE_SETUP_GUIDE.md b/CI_CD_PIPELINE_SETUP_GUIDE.md index 2de1062..b7bb16a 100644 --- a/CI_CD_PIPELINE_SETUP_GUIDE.md +++ b/CI_CD_PIPELINE_SETUP_GUIDE.md @@ -605,10 +605,29 @@ curl http://localhost:5000/v2/test/tags/list docker rmi localhost:5000/test:latest docker pull localhost:5000/test:latest -# Clean up test image +# Clean up test image completely +# Remove from local Docker docker rmi localhost:5000/test:latest + +# Delete test image from registry using registry API +# Get the digest of the latest tag +DIGEST=$(curl -s -H "Accept: application/vnd.docker.distribution.manifest.v2+json" http://localhost:5000/v2/test/manifests/latest | grep -o '"digest":"[^"]*"' | cut -d'"' -f4) + +# Delete the manifest from registry +if [ ! -z "$DIGEST" ]; then + echo "Deleting test image from registry..." + curl -X DELETE http://localhost:5000/v2/test/manifests/$DIGEST +else + echo "Could not find digest for test image" +fi + +# Clean up test file rm /tmp/test.Dockerfile +# Verify registry is empty +echo "Registry contents after cleanup:" +curl http://localhost:5000/v2/_catalog + # Exit SERVICE_USER shell exit ```