Notify projects automatically of autorelease build failure 96/51096/9
authorAnil Belur <abelur@linuxfoundation.org>
Thu, 26 Jan 2017 23:42:37 +0000 (15:42 -0800)
committerAnil Belur <abelur@linuxfoundation.org>
Mon, 13 Feb 2017 08:13:56 +0000 (18:13 +1000)
* Search patterns include both formats
    1. Full format:    ODL :: $PROJECT :: $ARTIFACTID
    2. Partial format: Building $ARTIFACTID
* Get project name from reactor summary for any failures
* Verify remote staging is completed succesfully
* Notify the release list and project list only on build failures
* For testing purposes have excluded mailing lists

Change-Id: I0252d18551c86f08a3f95d87cacc7722ec621082
Also-by: Thanh Ha <thanh.ha@linuxfoundation.org>
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
jjb/autorelease/autorelease-macros.yaml
jjb/autorelease/autorelease-templates.yaml
jjb/autorelease/include-raw-autorelease-notify-build-failure.sh [new file with mode: 0644]

index ad0838afa6a518420627274d300e3a28cc16f124..eccf27f5f696e2c2f86fa82310366fd6b59f8602 100644 (file)
         - shell: |
             ./scripts/fix-relativepaths.sh
 
+- builder:
+    # include-raw-autorelease-notify-build-failure.sh searches console log for
+    # failures and emails the status to the release mailing list.
+    name: opendaylight-infra-notify-status
+    builders:
+        - shell:
+            !include-raw-escape: include-raw-autorelease-notify-build-failure.sh
index 763fd60684bcec74cd9e1d67e0f51b90d3f4c00a..4a60321c14e05e2fadd6b040f003552cdb3b5a14 100644 (file)
@@ -88,6 +88,7 @@
             global-settings: 'odl-global-settings'
         - autorelease-maven-sources-post-process
         - autorelease-sys-stats
+        - opendaylight-infra-notify-status
         - shell: |
             mkdir -p archives/
             cp *.log *.prop $_
diff --git a/jjb/autorelease/include-raw-autorelease-notify-build-failure.sh b/jjb/autorelease/include-raw-autorelease-notify-build-failure.sh
new file mode 100644 (file)
index 0000000..0289110
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/bash -x
+# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+##############################################################################
+# Copyright (c) 2017 The Linux Foundation and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+##############################################################################
+
+#RELEASE_EMAIL="release@lists.opendaylight.org"
+RELEASE_EMAIL="abelur@linuxfoundation.org, thanh.ha@linuxfoundation.org"
+ARCHIVES_DIR="$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER"
+CONSOLE_LOG="/tmp/autorelease-build.log"
+
+BODY="Please refer to the logs server URL for console logs when possible
+and use the Jenkins Build URL as a last resort.
+
+Console Logs URL:
+https://logs.opendaylight.org/$SILO/$ARCHIVES_DIR
+
+Jenkins Build URL:
+$BUILD_URL"
+
+# get console logs
+wget -O $CONSOLE_LOG ${BUILD_URL}consoleText
+
+# get the failed project or artifactid
+TEMP=`awk '/Reactor Summary:/{flag=1;next} \
+           /Final Memory:/{flag=0}flag' $CONSOLE_LOGS \
+           | grep '. FAILURE \[' | awk -F'[].]' '{gsub(/ /, "", $2); print $2 }'`
+
+# check for project format
+if [[ ${TEMP} =~ .*::*.*::*. ]]; then
+    # extract project and artifactid from full format
+         PROJECT=`echo ${TEMP} | awk -F'::' '{ print $2 }'`
+         ARTIFACTID=`echo ${TEMP} |awk -F'::' '{ print $3 }'`
+else
+         # set ARTIFACTID to partial format
+         ARTIFACTID=${TEMP}
+fi
+
+# check if remote staging is complete successfully
+BUILD_STATUS=`awk '/\[INFO\] Remote staging finished/{flag=1;next} \
+                   /Total time:/{flag=0}flag' $CONSOLE_LOG \
+                   | grep '\] BUILD' | awk '{print $3}'`
+
+if [ ! -z "${ARTIFACTID}" ] && [[ "${BUILD_STATUS}" != "SUCCESS" ]]; then
+    # project search pattern should handle both scenarios
+    # 1. Full format:    ODL :: $PROJECT :: $ARTIFACTID
+    # 2. Partial format: Building $ARTIFACTID
+    awk "/\[INFO\] Building ${ARTIFACTID} / || /ODL :: ${PROJECT} :: ${ARTIFACTID} /{flag=1;next} \
+          /Reactor Summary:/{flag=0}flag" $CONSOLE_LOG > /tmp/error_msg
+
+    if [ -z "${PROJECT}" ]; then
+        PROJECT=${ARTIFACTID}
+        # TODO: unset the below line when ready to deploy to real lists
+        # RELEASE_EMAIL = "${RELEASE_EMAIL}, ${PROJECT}-dev@opendaylight.org"
+    fi
+
+    SUBJECT="[release] Autorelease build failure: ${PROJECT}"
+
+    echo "${BODY}" | mail -A /tmp/error_msg -s "${SUBJECT}" "${RELEASE_EMAIL}"
+fi
+
+rm $CONSOLE_LOG