Rework the messaging back to gerrit and improve escaping 88/22688/2
authorJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Tue, 15 Oct 2019 22:00:29 +0000 (00:00 +0200)
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Tue, 15 Oct 2019 22:03:04 +0000 (22:03 +0000)
This will allow to post more detailed messages back to gerrit.

Note the double quotes used and the eval before the ssh to enforce the expansion.

Signed-off-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org>
Change-Id: I1c0d618796ef1cb697529575f7b9925ae4926a97

jjb/common/include-agl-lava-jobs-submit.sh

index 92a5ce8..9b876bf 100644 (file)
@@ -144,14 +144,36 @@ if [ -s job-result.fail ];then
 fi
 
 set -x
-BUILD_LOG_MSG="LOGURL:\ ${BUILD_URL}consoleFull"
+MSG_FAIL="CI-Image-Boot-Test fail on ${MACHINE}"
+MSG_SUCCESS="CI-Image-Boot-Test success on ${MACHINE}"
+MSG_BUILD_LOG="${BUILD_URL}consoleFull"
+MSG_JOBFAIL="Failed jobs:
+$(cat job-result.fail)"
 
 if [ $GOODJOB -eq 0 ];then
+        #construct message
+cat << EOF > .msg
+$MSG_FAIL
+
+Build log available at: $MSG_BUILD_LOG
+
+$MSG_JOBFAIL
+EOF
+        # escape
+        sed -i -e "s/ /\\\ /g" .msg
        # send -1
-       ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -p 29418 agl-jobbuilder@gerrit.automotivelinux.org gerrit review ${GERRIT_CHANGE_NUMBER},${GERRIT_PATCHSET_NUMBER} --verified +1 --label ci-image-boot-test=-1 -n NONE --message="CI-Image-Boot-Test\ fail\ on\ ${MACHINE}\ ${BUILD_LOG_MSG}" || true
+       eval ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -p 29418 agl-jobbuilder@gerrit.automotivelinux.org gerrit review ${GERRIT_CHANGE_NUMBER},${GERRIT_PATCHSET_NUMBER} --verified +1 --label ci-image-boot-test=-1 -n NONE --message='"$(cat .msg)"' || true
 else
+        #construct message
+cat << EOF > .msg
+$MSG_SUCCESS
+
+Build log available at: $MSG_BUILD_LOG
+EOF
+        # escape
+        sed -i -e "s/ /\\\ /g" .msg
        # send +1
-       ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -p 29418 agl-jobbuilder@gerrit.automotivelinux.org gerrit review ${GERRIT_CHANGE_NUMBER},${GERRIT_PATCHSET_NUMBER} --verified +1 --label ci-image-boot-test=+1 -n NONE --message="CI-Image-Boot-Test\ success\ on\ ${MACHINE}\ ${BUILD_LOG_MSG}" || true
+       eval ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -p 29418 agl-jobbuilder@gerrit.automotivelinux.org gerrit review ${GERRIT_CHANGE_NUMBER},${GERRIT_PATCHSET_NUMBER} --verified +1 --label ci-image-boot-test=+1 -n NONE --message='"$(cat .msg)"' || true
 fi
 set +x