tf-ci-scripts: add support for IAR images
This adds support for the cleanup and building of the IAR
docker images that reside in a private repo.
It mirrors the work used for the misra docker images.
Change-Id: I7965b6bec555f8b11a8b3f23c8cf971005b03653
diff --git a/ci-dockerslaves-cleanup.yaml b/ci-dockerslaves-cleanup.yaml
index edffffa..d5d5881 100644
--- a/ci-dockerslaves-cleanup.yaml
+++ b/ci-dockerslaves-cleanup.yaml
@@ -52,6 +52,8 @@
!include-raw: ci-dockerfiles-deployment/cleanup-update.sh
- shell:
!include-raw: misra-docker-images/update.sh
+ - shell:
+ !include-raw: iar-docker-images/update.sh
publishers:
- email:
diff --git a/iar-docker-images.yaml b/iar-docker-images.yaml
new file mode 100644
index 0000000..883d959
--- /dev/null
+++ b/iar-docker-images.yaml
@@ -0,0 +1,47 @@
+- job:
+ name: iar-docker-images
+ project-type: freestyle
+ defaults: global
+ properties:
+ - authorization:
+ anonymous:
+ - job-read
+ - job-extended-read
+ - build-discarder:
+ days-to-keep: 500
+ num-to-keep: 30
+ disabled: false
+ node: build-amd64-private
+ concurrent: false
+ display-name: 'IAR Docker images build'
+ parameters:
+ - string:
+ name: GERRIT_PROJECT
+ default: 'ci/iar-dockerfiles'
+ description: |
+ Git project to build (also set by Gerrit trigger)
+ - string:
+ name: GERRIT_BRANCH
+ default: 'master'
+ description: |
+ Git branch to build (also set by Gerrit trigger)
+ - string:
+ name: GERRIT_REFSPEC
+ default: ''
+ scm:
+ - git:
+ url: https://review.trustedfirmware.org/${GERRIT_PROJECT}
+ refspec: ${GERRIT_REFSPEC}
+ branches:
+ - ${GERRIT_BRANCH}
+ skip-tag: true
+ clean:
+ before: true
+ choosing-strategy: gerrit
+ basedir: iar-dockerfiles
+ builders:
+ - shell:
+ !include-raw: iar-docker-images/builders.sh
+ publishers:
+ - email:
+ recipients: 'linaro-infrastructure-errors@lists.linaro.org arthur.she@linaro.org'
diff --git a/iar-docker-images/builders.sh b/iar-docker-images/builders.sh
new file mode 100755
index 0000000..19f7216
--- /dev/null
+++ b/iar-docker-images/builders.sh
@@ -0,0 +1,52 @@
+#!/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
+
+cd iar-dockerfiles
+
+aws configure list
+export ECR=987685672616.dkr.ecr.us-east-1.amazonaws.com
+# we are expecting private files to be kept in the dockerfiles/*
+# subdirs with a matching name for the image
+aws s3 cp --recursive s3://trustedfirmware-iar/dockerfiles/ .
+find .
+aws ecr get-login-password --region us-east-1|docker login --username AWS --password-stdin $ECR
+
+
+was_error=0
+
+for image in ./*
+do
+ tag=$(basename $image)
+ test -d $image && test -f $image/build.sh && \
+ (
+ echo "=== Building image: iar:${tag} ==="
+ set -ex
+ touch /tmp/dckr-img-err
+ cd $image
+ ./build.sh
+ echo "Uploading image: iar:${tag}"
+ docker push $ECR/iar:$tag
+ rm -f /tmp/dckr-img-err
+ )
+
+ if [ -f /tmp/dckr-img-err ]; then
+ was_error=1
+ echo "ERROR building image: iar:${tag}"
+ fi
+done
+
+if [ "$was_error" == "1" ]; then
+ echo "---------------------------------"
+ echo "At least one image FAILED to build successfully. See the log above for ERRORs."
+ exit 1
+fi
diff --git a/iar-docker-images/update.sh b/iar-docker-images/update.sh
new file mode 100755
index 0000000..3f8fc34
--- /dev/null
+++ b/iar-docker-images/update.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+set -e
+
+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=iar
+aws ecr get-login-password --region us-east-1|docker login --username AWS --password-stdin $ECR
+
+for image in $(aws ecr list-images --region us-east-1 --repository-name $REPO | \
+ grep imageTag | \
+ awk '{print $2}' | \
+ sed 's/"//g'); do
+
+ docker pull $ECR/$REPO:$image
+done