2 # @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
12 RELEASE_EMAIL="release@lists.opendaylight.org"
13 ARCHIVES_DIR="$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER"
14 CONSOLE_LOG="/tmp/autorelease-build.log"
15 STREAM=${JOB_NAME#*-*e-}
18 wget -O $CONSOLE_LOG ${BUILD_URL}consoleText
20 # extract the failing project or artifactid
21 REACTOR_INFO=`awk '/Reactor Summary:/ { flag=1 }
23 if ( sub(/^\[(INFO)\]/,"") && sub(/FAILURE \[.*/,"") ) {
24 gsub(/[[:space:]]*::[[:space:]]*/,"::")
25 gsub(/^[[:space:]]+|[[:space:]]+$|[.]/,"")
29 /Final Memory:/ { flag=0 }' $CONSOLE_LOG`
31 # check for project format
32 if [[ ${REACTOR_INFO} =~ .*::*.*::*. ]]; then
33 # extract project and artifactid from full format
34 ODL=`echo ${REACTOR_INFO} | awk -F'::' '{ gsub(/^[ \t]+|[ \t]+$/, "", $1); print $1 }'`
35 PROJECT=`echo ${REACTOR_INFO} | awk -F'::' '{ gsub(/^[ \t]+|[ \t]+$/, "", $2); print $2 }'`
36 ARTIFACTID=`echo ${REACTOR_INFO} | awk -F'::' '{ gsub(/^[ \t]+|[ \t]+$/, "", $3); print $3 }'`
38 # set ARTIFACTID to partial format
41 ARTIFACTID=`echo ${REACTOR_INFO} | awk '{ gsub(/^[ \t]+|[ \t]+$/, ""); print }'`
44 # Construct email subject & body
45 PROJECT_STRING=${PROJECT:+" from $PROJECT"}
46 SUBJECT="[release] Autorelease $STREAM failed to build $ARTIFACTID$PROJECT_STRING"
47 BODY="Attention$PROJECT_STRING,
49 Autorelease $STREAM failed to build $ARTIFACTID$PROJECT_STRING in build
50 $BUILD_NUMBER. Attached is a snippet of the error message related to the
51 failure that we were able to automatically parse as well as console logs.
54 https://logs.opendaylight.org/$SILO/$ARCHIVES_DIR
59 Please review and provide an ETA on when a fix will be available.
62 ODL releng/autorelease team
65 # check if remote staging is complete successfully
66 BUILD_STATUS=`awk '/\[INFO\] Remote staging finished/{flag=1;next} \
67 /Total time:/{flag=0}flag' $CONSOLE_LOG \
68 | grep '\] BUILD' | awk '{print $3}'`
70 if [ ! -z "${ARTIFACTID}" ] && [[ "${BUILD_STATUS}" != "SUCCESS" ]]; then
71 # project search pattern should handle both scenarios
72 # 1. Full format: ODL :: $PROJECT :: $ARTIFACTID
73 # 2. Partial format: Building $ARTIFACTID
74 sed -e "/\[INFO\] Building \(${ARTIFACTID} \|${ODL} :: ${PROJECT} :: ${ARTIFACTID} \)/,/Reactor Summary:/!d;//d" \
75 $CONSOLE_LOG > /tmp/error_msg
77 if [ -n "${PROJECT}" ]; then
78 RELEASE_EMAIL="${RELEASE_EMAIL}, ${PROJECT}-dev@opendaylight.org"
81 echo "${BODY}" | mail -a /tmp/error_msg \
82 -S "from=Jenkins <jenkins-dontreply@opendaylight.org>" \
83 -s "${SUBJECT}" "${RELEASE_EMAIL}"