Arthur: Add iar-docker-images job
Signed-off-by: Arthur She <arthur.she@linaro.org>
Change-Id: Idf40b33a93b4da512d8363e29f1e0701f6c51096
diff --git a/iar-docker-images.yaml b/iar-docker-images.yaml
new file mode 100644
index 0000000..efddf2f
--- /dev/null
+++ b/iar-docker-images.yaml
@@ -0,0 +1,58 @@
+- job:
+ name: iar-docker-images
+ project-type: freestyle
+ defaults: global
+ properties:
+ - build-discarder:
+ days-to-keep: 500
+ num-to-keep: 30
+ disabled: false
+ # Test build job on TF-02
+ node: build-amd64
+# node: build-amd64-private
+ concurrent: false
+ display-name: 'TF-M IAR Docker images build job'
+ 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: ''
+ wrappers:
+ - timestamps
+ - timeout:
+ timeout: 60
+ fail: true
+ - credentials-binding:
+ - text:
+ credential-id: TEST_IAR_LICENSE_NR
+ variable: IAR_LICENSE_NR
+ - text:
+ credential-id: TEST_IAR_LICENSE_EMAIL
+ variable: IAR_LICENSE_EMAIL
+ 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: 'arthur.she@linaro.org'
+
diff --git a/iar-docker-images/builders.sh b/iar-docker-images/builders.sh
new file mode 100755
index 0000000..2c4de52
--- /dev/null
+++ b/iar-docker-images/builders.sh
@@ -0,0 +1,51 @@
+#!/bin/bash
+
+docker --version
+
+ON_EC2="0"
+if [ -f /sys/hypervisor/uuid ] && grep -q ^ec2 /sys/hypervisor/uuid; then
+ ON_EC2="1"
+fi
+
+if [ "${ON_EC2}" == "1" ]; then
+ 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
+ # 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-misra/dockerfiles/ .
+ # Get armclang toolchain
+ aws s3 cp --recursive s3://trustedfirmware-private/armclang/ .
+ find .
+ aws ecr get-login-password --region us-east-1|docker login --username AWS --password-stdin $ECR
+fi
+
+# Test on TF-02, copy armclang and IAR toolchain to the working dir
+cp /home/arthur.she/toolchain/* .
+
+cd iar-dockerfiles
+
+image=$(dirname $(find . -name build.sh))
+test -d $image && test -f $image/build.sh && \
+(
+ echo "=== Building image: $image ==="
+ set -ex
+ touch /tmp/dckr-img-err
+ cd $image
+ ./build.sh --build-arg IAR_LIC_NR=${IAR_LICENSE_NR} --build-arg IAR_LIC_EMAIL=${IAR_LICENSE_EMAIL}
+# echo "Uploading image: ${tag}"
+# docker push $ECR/misra:$tag
+ rm -f /tmp/dckr-img-err
+)
+
+if [ -f /tmp/dckr-img-err ]; then
+ was_error=1
+ echo "ERROR building image: misra:${tag}"
+fi