Add build-aws-amis.yaml

This job is used for building AWS AMIs

Signed-off-by: Arthur She <arthur.she@linaro.org>
Change-Id: I4eeb49ffad1eeae017ff1585f5ec460a2591aa46
diff --git a/build-aws-amis.yaml b/build-aws-amis.yaml
new file mode 100644
index 0000000..da554cc
--- /dev/null
+++ b/build-aws-amis.yaml
@@ -0,0 +1,59 @@
+- job:
+    name: build-aws-amis
+    project-type: freestyle
+    defaults: global
+    properties:
+        - authorization:
+            anonymous:
+                - job-read
+                - job-extended-read
+        - build-discarder:
+            days-to-keep: 90
+            num-to-keep: 200
+    disabled: false
+    node: build-amd64-private
+    concurrent: false
+    display-name: 'Build AWS AMI'
+    wrappers:
+        - timestamps
+    parameters:
+    - bool:
+        name: BUILD_UBUNTU_AMI
+        default: true
+        description: Build Ubuntu AMI
+    - bool:
+        name: BUILD_FREEBSD_AMI
+        default: false
+        description: Build FreeBSD AMI
+    - bool:
+        name: BUILD_CUSTOM_AMI
+        default: false
+        description: Build Custom AMI
+    builders:
+        - shell: |
+            #!/bin/bash
+
+            export PACKER_LOG=1
+
+            AMI=""
+            [ ${BUILD_UBUNTU_AMI} == "true" ] && AMI="${AMI} ubuntu"
+            [ ${BUILD_FREEBSD_AMI} == "true" ] && AMI="${AMI} freebsd"
+            [ ${BUILD_CUSTOM_AMI} == "true" ] && AMI="${AMI} custom"
+
+            [ -z "${AMI}" ] && echo "Build Nothing.." && exit
+
+            rm -rf mbedtls-amis
+            git clone https://git.trustedfirmware.org/ci/aws-amis.git
+            cd mbedtls-amis
+
+            for os in ${AMI}
+            do
+                echo -e "\nBuild ${os} AMI"
+                [ ! -f "packer_${os}.json" ] && echo -e "\nERROR: Can not find packer_${os}.json" && exit -1
+                # Dump packer_config.json to job log
+                cat packer_${os}.json
+                packer build packer_${os}.json
+            done
+    publishers:
+        - email:
+            recipients: linaro-infrastructure-errors@lists.linaro.org,arthur.she@linaro.org