ci-dockerfiles-sanity-check: new job
Job to verify if new dockerfiles build succeed/fail
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Change-Id: Id1405c19604a63af503dc268f5a86bd9fa086d70
diff --git a/ci-dockerfiles-deployment/builders.sh b/ci-dockerfiles-deployment/builders.sh
index e4f58e0..fea77b3 100644
--- a/ci-dockerfiles-deployment/builders.sh
+++ b/ci-dockerfiles-deployment/builders.sh
@@ -2,33 +2,20 @@
set -ex
-trap cleanup_exit INT TERM EXIT
-
-cleanup_exit()
-{
- rm -rf ${HOME}/.docker
- rm -f ${WORKSPACE}/{log,config.json,version.txt}
-}
-
-mkdir -p ${HOME}/.docker
-wget https://ci.trustedfirmware.org/userContent/config.json
-sed -e "s|\${DOCKER_AUTH}|${DOCKER_AUTH}|" < ${WORKSPACE}/config.json > ${HOME}/.docker/config.json
-chmod 0600 ${HOME}/.docker/config.json
-
echo ""
echo "########################################################################"
echo " Gerrit Environment"
env |grep '^GERRIT'
echo "########################################################################"
-rm -f ${WORKSPACE}/{log,config.json,version.txt}
+rm -f ${WORKSPACE}/log
cd dockerfiles/
git_previous_commit=$(git rev-parse HEAD~1)
git_commit=$(git rev-parse HEAD)
files=$(git diff --name-only ${git_previous_commit} ${git_commit})
echo Changes in: ${files}
-changed_dirs=$(dirname ${files})
+changed_dirs=$(dirname ${files}|sort -u)
update_images=""
for dir in ${changed_dirs}; do
@@ -45,6 +32,9 @@
# images to the list.
update_images="${update_images} $(dirname $(find . -path "*-${dir_basename}*/build.sh" | sed -e "s#^\./##g"))"
;;
+ ".")
+ continue
+ ;;
*)
update_images="${update_images} $(dirname $(find ${dir} -name build.sh))"
;;
@@ -80,21 +70,6 @@
echo "Skipping: can't build for ${image_arch} on ${host_arch}"
;;
esac
- if [ -r .docker-tag ]; then
- docker_tag=$(cat .docker-tag)
- if [ x"${GERRIT_BRANCH}" != x"master" ]; then
- new_tag=${docker_tag}-${GERRIT_BRANCH}
- docker tag ${docker_tag} ${new_tag}
- docker_tag=${new_tag}
- fi
- docker push ${docker_tag}
- fi
)||echo $image failed >> ${WORKSPACE}/log
done
-if [ -e ${WORKSPACE}/log ]
-then
- echo "some images failed:"
- cat ${WORKSPACE}/log
- exit 1
-fi
diff --git a/ci-dockerfiles-deployment/publish.sh b/ci-dockerfiles-deployment/publish.sh
new file mode 100644
index 0000000..9d71f3e
--- /dev/null
+++ b/ci-dockerfiles-deployment/publish.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+set -ex
+
+trap cleanup_exit INT TERM EXIT
+
+cleanup_exit()
+{
+ rm -rf ${HOME}/.docker
+ rm -f ${WORKSPACE}/{log,config.json,version.txt}
+}
+
+docker_log_in()
+{
+ mkdir -p ${HOME}/.docker
+ sed -e "s|\${DOCKER_AUTH}|${DOCKER_AUTH}|" < ${WORKSPACE}/config.json > ${HOME}/.docker/config.json
+ chmod 0600 ${HOME}/.docker/config.json
+}
+
+update_images=$(find -type f -name .docker-tag)
+docker_log_in
+for imagename in ${update_images}; do
+ (
+ docker_tag=$(cat $imagename)
+ if [ x"${GERRIT_BRANCH}" != x"master" ]; then
+ new_tag=${docker_tag}-${GERRIT_BRANCH}
+ docker tag ${docker_tag} ${new_tag}
+ docker_tag=${new_tag}
+ fi
+ for i in 30 60 120;
+ do
+ docker push ${docker_tag} && exit 0 || true
+ sleep $i
+ docker_log_in
+ done
+ exit 1
+ )||echo $imagename push failed >> ${WORKSPACE}/log
+done
+
+if [ -e ${WORKSPACE}/log ]
+then
+ echo "some images failed:"
+ cat ${WORKSPACE}/log
+ exit 1
+fi
diff --git a/ci-dockerfiles-deployment/report.sh b/ci-dockerfiles-deployment/report.sh
new file mode 100644
index 0000000..fe0ac53
--- /dev/null
+++ b/ci-dockerfiles-deployment/report.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+set -ex
+
+trap cleanup_exit INT TERM EXIT
+
+cleanup_exit()
+{
+ rm -rf ${HOME}/.docker
+ rm -f ${WORKSPACE}/{log,config.json,version.txt}
+}
+
+update_images=$(find -type f -name .docker-tag)
+
+for imagename in ${update_images}; do
+ (
+ docker_tag=$(cat $imagename)
+ if [ x"${GERRIT_BRANCH}" != x"master" ]; then
+ new_tag=${docker_tag}-${GERRIT_BRANCH}
+ docker tag ${docker_tag} ${new_tag}
+ docker_tag=${new_tag}
+ fi
+ echo successful build ${docker_tag}
+ )
+done
+
+if [ -e ${WORKSPACE}/log ]
+then
+ echo "some images failed:"
+ cat ${WORKSPACE}/log
+ exit 1
+fi