Skip to content
Snippets Groups Projects
Commit 11653cd3 authored by Julien Leduc's avatar Julien Leduc
Browse files

Adding a script to rename images

parent 6050bfc8
No related branches found
No related tags found
No related merge requests found
......@@ -65,14 +65,7 @@ ctafrontend_docker_rename:
REPOSITORY: cta/cta-orchestration
GITLAB_HOST: gitlab.cern.ch
script:
- OLDTAG=${CI_PIPELINE_ID}
- NEWTAG=${CTA_BUILD_ID}
- JWT_PULL_PUSH_TOKEN=$(curl -q -u ${DOCKER_LOGIN_USERNAME}:${DOCKER_LOGIN_PASSWORD} "https://${GITLAB_HOST}/jwt/auth?service=container_registry&scope=repository:${REPOSITORY}:pull,push" | jq .token -r)
- echo "List of tags in registry"
- curl "https://${CI_REGISTRY}/v2/${REPOSITORY}/tags/list" -H "Authorization: Bearer ${JWT_PULL_PUSH_TOKEN}"
- echo "Pulling the manifest of tag:${OLDTAG}"
- curl "https://${CI_REGISTRY}/v2/${REPOSITORY}/manifests/${OLDTAG}" -H "Authorization: Bearer ${JWT_PULL_PUSH_TOKEN}" -H 'accept: application/vnd.docker.distribution.manifest.v2+json' > manifest.json
- echo "Pushing new tag: ${NEWTAG}"
- curl -XPUT "https://${CI_REGISTRY}/v2/${REPOSITORY}/manifests/${NEWTAG}" -H "Authorization: Bearer ${JWT_PULL_PUSH_TOKEN}" -H 'content-type: application/vnd.docker.distribution.manifest.v2+json' -d '@manifest.json' -v
- echo "List of tags in registry"
- curl "https://${CI_REGISTRY}/v2/${REPOSITORY}/tags/list" -H "Authorization: Bearer ${JWT_PULL_PUSH_TOKEN}"
- export OLDTAG=${CI_PIPELINE_ID}
- export NEWTAG=${CTA_BUILD_ID}
- cd continuousintegration/ci_helpers/
- ./rename_tag.sh
#!/bin/bash
# env variables used:
# DOCKER_LOGIN_USERNAME
# DOCKER_LOGIN_PASSWORD
# OLDTAG
# NEWTAG
# TO=gitlab-registry.cern.ch/cta/cta-orchestration
CI_REGISTRY=$(echo ${TO} | sed -e 's%/.*%%')
REPOSITORY=$(echo ${TO} | sed -e 's%[^/]\+/%%')
GITLAB_HOST=gitlab.cern.ch
JWT_PULL_PUSH_TOKEN=$(curl -q -u ${DOCKER_LOGIN_USERNAME}:${DOCKER_LOGIN_PASSWORD} \
"https://${GITLAB_HOST}/jwt/auth?service=container_registry&scope=repository:${REPOSITORY}:pull,push" | jq .token -r)
echo "List of tags in registry"
curl "https://${CI_REGISTRY}/v2/${REPOSITORY}/tags/list" -H "Authorization: Bearer ${JWT_PULL_PUSH_TOKEN}"
echo "Pulling the manifest of tag:${OLDTAG}"
curl "https://${CI_REGISTRY}/v2/${REPOSITORY}/manifests/${OLDTAG}" -H "Authorization: Bearer ${JWT_PULL_PUSH_TOKEN}" -H 'accept: application/vnd.docker.distribution.manifest.v2+json' > manifest.json
echo "Pushing new tag: ${NEWTAG}"
curl -XPUT "https://${CI_REGISTRY}/v2/${REPOSITORY}/manifests/${NEWTAG}" -H "Authorization: Bearer ${JWT_PULL_PUSH_TOKEN}" -H 'content-type: application/vnd.docker.distribution.manifest.v2+json' -d '@manifest.json' -v
echo "List of tags in registry"
curl "https://${CI_REGISTRY}/v2/${REPOSITORY}/tags/list" -H "Authorization: Bearer ${JWT_PULL_PUSH_TOKEN}"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment