Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 18 lines (13 sloc) 713 Bytes
#!/bin/bash
set -e;
if [ -z "$VERSION" ]; then
echo "ERROR: No VERSION environment variable set";
exit 1;
fi
IMAGE_NAME=$(echo $CI_REGISTRY_IMAGE | cut -d '/' -f2-)
export GITLAB_TOKEN=$(curl -s --user "${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}" "https://${CI_SERVER_HOST}/jwt/auth?offline_token=true&service=container_registry&scope=repository:${IMAGE_NAME}:pull" | jq -r ".token")
if ! curl --fail -s -I -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -H "Authorization: Bearer $GITLAB_TOKEN" "https://${CI_REGISTRY}/v2/${IMAGE_NAME}/manifests/${VERSION}"; then
echo "ERROR: Image version ${IMAGE_NAME}:${VERSION} not found in registry $CI_REGISTRY";
exit 1;
fi
exit 0;
You can’t perform that action at this time.