Skip to content

Instantly share code, notes, and snippets.

@xiaket
Created August 10, 2018 01:52
Show Gist options
  • Save xiaket/4a5d8eec5f551b0883f3f615ad180672 to your computer and use it in GitHub Desktop.
Save xiaket/4a5d8eec5f551b0883f3f615ad180672 to your computer and use it in GitHub Desktop.
Bash script to add tag to docker images in ECR
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
REPO_NAME="jenkins-master"
function manifest() {
aws ecr batch-get-image --repository-name "$REPO_NAME" --image-ids imageDigest=$1 --query 'images[].imageManifest' --output text
}
function retag () {
JSON=`manifest $1`
aws ecr put-image --repository-name "$REPO_NAME" --image-tag $2 --image-manifest "$JSON" >/dev/null
}
retag sha256:15d084d4957c72c294dd320303a10e1b359e1bdcfd2348b0d693d36bdc571700 feature-bb
retag sha256:a6429d3dff00b97c988236c5133abe072718e1864662cb80e8db43408e7a6c42 feature-aa
retag sha256:19051de5aaf237e040645165bc72d7ff0be59406c28f6cb47c1dcc1f7884c458 master-12
retag sha256:7eab583c2eb0f3e512f1c85e463c33b1daae01b51651795c9699b78af1bea8c3 master-13
retag sha256:a4aa69df995674f52fcd8d8163c13570237abab4483decfa7f3a35222790087d develop-10
retag sha256:837cf93986ae9bf00eafd3881ea8c3d803b67093087e1475be48d6f8cd5c6409 develop-4
retag sha256:797434e990b0a16aae02ee2713109e6e71f7226257e8f8e5f5d8e328453c3e36 bugfix-cc
retag sha256:0fb032384c010fce68fd308765531c9de6c480c47439196a283192f8d4fb0efd master-9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment