ci-dockerslaves-cleanup: add MISRA update from ECR
As part of the docker image cleanup routine on the Jenkins agents,
we should be attempting to update any of the MISRA images from
the private ECR so that they're available for Jenkins use.
This changes adds in an update script in misra-docker-images/update.sh,
and then adds it to the periodic job run to clean up all Jenkins agents.
Note that this change applies to production rather than staging even
though the MISRA images are only used in staging. This is because both
production and staging use the same Jenkins agents, and the cleanup script
is only run from production to prevent competing cleanup processes from
interfering w/ each other.
Signed-off-by: Kelley Spoon <kelley.spoon@linaro.org>
Change-Id: Icbad25863176413d30bc0289884d0ad037c20bcd
diff --git a/misra-docker-images/update.sh b/misra-docker-images/update.sh
new file mode 100755
index 0000000..010a5d1
--- /dev/null
+++ b/misra-docker-images/update.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+docker --version
+
+if ! type aws
+then
+ sudo apt-get -y -qq update
+ sudo apt-get -y -qq install --no-install-recommends unzip
+ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
+ unzip awscliv2.zip
+ sudo ./aws/install
+fi
+
+aws configure list
+export ECR=987685672616.dkr.ecr.us-east-1.amazonaws.com
+export REPO=misra
+aws ecr get-login-password --region us-east-1|docker login --username AWS --password-stdin $ECR
+
+for image in $(aws ecr list-images --repository-name $REPO | \
+ grep imageTag | \
+ awk '{print $2}' | \
+ sed 's/"//g'); do
+
+ docker pull $ECR/$REPO:$image
+done