Update iar-docker-images.yaml

Signed-off-by: Arthur She <arthur.she@linaro.org>
Change-Id: Iebb1f6600ab18c6f2a4d7ce11fd8d90863ddf332
diff --git a/iar-docker-images.yaml b/iar-docker-images.yaml
index 883d959..8ec7749 100644
--- a/iar-docker-images.yaml
+++ b/iar-docker-images.yaml
@@ -3,17 +3,13 @@
     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'
+    display-name: 'TF-M IAR Docker images builder'
     parameters:
         - string:
             name: GERRIT_PROJECT
@@ -28,6 +24,23 @@
         - string:
             name: GERRIT_REFSPEC
             default: ''
+        - string:
+            name: IAR_PACKAGE
+            default: 'bxarm-9.50.2.deb'
+            description: |
+              IAR toolchain install package file name
+    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}
@@ -44,4 +57,5 @@
             !include-raw: iar-docker-images/builders.sh
     publishers:
         - email:
-            recipients: 'linaro-infrastructure-errors@lists.linaro.org arthur.she@linaro.org'
+            recipients: 'arthur.she@linaro.org'
+
diff --git a/iar-docker-images/builders.sh b/iar-docker-images/builders.sh
index 19f7216..ce2e29a 100755
--- a/iar-docker-images/builders.sh
+++ b/iar-docker-images/builders.sh
@@ -1,7 +1,11 @@
 #!/bin/bash
 
+set -ex
+
 docker --version
 
+cd iar-dockerfiles
+
 if ! type aws
 then
     sudo apt-get -y -qq update
@@ -11,42 +15,24 @@
     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/ .
+ECR=987685672616.dkr.ecr.us-east-1.amazonaws.com
+export IAR_ECR=987685672616.dkr.ecr.us-east-1.amazonaws.com/iar
+# Get armclang toolchain
+aws s3 cp --recursive s3://trustedfirmware-private/armclang/ .
+# Get IAR toolchain binary
+aws s3 cp --recursive s3://trustedfirmware-iar/ .
 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
+image=$(dirname $(find . -name build.sh))
+test -d $image  && test -f $image/build.sh && \
+(
+    echo "=== Building image: $image  ==="
+    set -ex
+    cd $image
+    ./build.sh --build-arg IAR_LIC_NR=${IAR_LICENSE_NR} --build-arg IAR_LIC_EMAIL=${IAR_LICENSE_EMAIL} --build-arg IAR_PACKAGE=${IAR_PACKAGE}
+    [ -f ".docker-tag" ] && tag=$(cat .docker-tag) || (echo "Docker image built failed!"; exit 1)
+    echo "Uploading image: ${tag}"
+    docker push $tag
+)