Created
April 28, 2022 12:07
-
-
Save gmolveau/72ab3e3ef89f598f614eca8a92a88ef1 to your computer and use it in GitHub Desktop.
nexus docker registry delete image by tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# inspiration/source : https://gist.github.com/matzegebbe/a2678b227add6bafad9a3a802618b5ad + https://issues.sonatype.org/browse/NEXUS-12711 | |
NEXUS_HOST="nexus.domain.tld" | |
NEXUS_REPOSITORY="docker" | |
NEXUS_USER="service" | |
NEXUS_PASSWORD="password" | |
IMAGE="python" | |
TAG="latest" | |
SHA256=$(curl --head -s -L -k -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -u "$NEXUS_USER:$NEXUS_PASSWORD" "http://$NEXUS_HOST/repository/$NEXUS_REPOSITORY/v2/$IMAGE/manifests/$TAG" | grep "docker-content-digest" | cut -d ":" -f3 | tr -d '\r') | |
STATUS=$(curl -s -o /dev/null -w "%{http_code}\n" -k -L -X DELETE -u "$NEXUS_USER:$NEXUS_PASSWORD" "http://$NEXUS_HOST/repository/$REPOSITORY/v2/$IMAGE/manifests/sha256:$SHA256") | |
[ "$STATUS" != "202" ] && ( | |
echo "status_code $STATUS != 202" | |
exit 1 | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment