diff --git a/entrypoint.sh b/entrypoint.sh index 386ec8fc8e1f846cf368d418eef4f166c53d653e..099cb1bd4cad5dd9c39672fa1a50c4c048276b34 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -27,13 +27,16 @@ TEMPFILE="$(mktemp)" CONTENT_TYPE="application/vnd.docker.distribution.manifest.v2+json" TOKEN="$(curl --user "${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}" "${SERVER_HOST_SCHEMA:-https}://${CI_SERVER_HOST}/jwt/auth?offline_token=true&service=container_registry&scope=repository:${CI_PROJECT_PATH}:push,pull" 2> "${TEMPFILE}" | jq -r .token)" -test -z "${TOKEN}" && ( cat "${TEMPFILE}"; die "Couldn't get token" ) +test -z "${TOKEN}" && ( cat "${TEMPFILE}"; ( test -z "${RETAG_DEBUG}" || die "Couldn't get token" ) ) +test -z "${RETAG_DEBUG}" || echo "Token: [${TOKEN}]" MANIFEST="$(curl -H "${CONTENT_TYPE}" -H "Authorization: Bearer ${TOKEN}" "${REGISTRY_SCHEMA:-https}://${CI_REGISTRY}/v2/${IMAGE_PATH}/manifests/${REGISTRY_TAG_OLD}" 2> "${TEMPFILE}")" -test -z "${MANIFEST}" && ( cat "${TEMPFILE}"; die "Couldn't get manifest" ) +test -z "${MANIFEST}" && ( cat "${TEMPFILE}"; ( test -z "${RETAG_DEBUG}" || die "Couldn't get manifest" ) ) +test -z "${RETAG_DEBUG}" || echo "Manifest: [${MANIFEST}]" -curl -X PUT -H "Content-Type: ${CONTENT_TYPE}" -H "Authorization: Bearer ${TOKEN}" -d "${MANIFEST}" "${REGISTRY_SCHEMA:-https}://${CI_REGISTRY}/v2/${IMAGE_PATH}/manifests/${REGISTRY_TAG_NEW}" 2> "${TEMPFILE}" -test "$?" -gt 0 && ( cat "${TEMPFILE}"; die "Couldn't retag image" ) +RESPONCE=$(curl -X PUT -H "Content-Type: ${CONTENT_TYPE}" -H "Authorization: Bearer ${TOKEN}" -d "${MANIFEST}" "${REGISTRY_SCHEMA:-https}://${CI_REGISTRY}/v2/${IMAGE_PATH}/manifests/${REGISTRY_TAG_NEW}" 2> "${TEMPFILE}") +test "$?" -gt 0 && ( cat "${TEMPFILE}"; ( test -z "${RETAG_DEBUG}" || die "Couldn't retag image" ) ) +test -z "${RETAG_DEBUG}" || echo "Responce: [${RESPONCE}]" echo "Image tag: ${CI_REGISTRY}/${IMAGE_PATH}:${REGISTRY_TAG_NEW}"