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-}
17 BODY="Please refer to the logs server URL for console logs when possible
18 and use the Jenkins Build URL as a last resort.
21 https://logs.opendaylight.org/$SILO/$ARCHIVES_DIR
27 wget -O $CONSOLE_LOG ${BUILD_URL}consoleText
29 # extract the failing project or artifactid
30 REACTOR_INFO=`awk '/Reactor Summary:/ { flag=1 }
32 if ( sub(/^\[(INFO)\]/,"") && sub(/FAILURE \[.*/,"") ) {
33 gsub(/[[:space:]]*::[[:space:]]*/,"::")
34 gsub(/^[[:space:]]+|[[:space:]]+$|[.]/,"")
38 /Final Memory:/ { flag=0 }' $CONSOLE_LOG`
40 # check for project format
41 if [[ ${REACTOR_INFO} =~ .*::*.*::*. ]]; then
42 # extract project and artifactid from full format
43 ODL=`echo ${REACTOR_INFO} | awk -F'::' '{ gsub(/^[ \t]+|[ \t]+$/, "", $1); print $1 }'`
44 PROJECT=`echo ${REACTOR_INFO} | awk -F'::' '{ gsub(/^[ \t]+|[ \t]+$/, "", $2); print $2 }'`
45 ARTIFACTID=`echo ${REACTOR_INFO} | awk -F'::' '{ gsub(/^[ \t]+|[ \t]+$/, "", $3); print $3 }'`
47 # set ARTIFACTID to partial format
50 ARTIFACTID=`echo ${REACTOR_INFO} | awk '{ gsub(/^[ \t]+|[ \t]+$/, ""); print }'`
53 # check if remote staging is complete successfully
54 BUILD_STATUS=`awk '/\[INFO\] Remote staging finished/{flag=1;next} \
55 /Total time:/{flag=0}flag' $CONSOLE_LOG \
56 | grep '\] BUILD' | awk '{print $3}'`
58 if [ ! -z "${ARTIFACTID}" ] && [[ "${BUILD_STATUS}" != "SUCCESS" ]]; then
59 # project search pattern should handle both scenarios
60 # 1. Full format: ODL :: $PROJECT :: $ARTIFACTID
61 # 2. Partial format: Building $ARTIFACTID
62 sed -e "/\[INFO\] Building \(${ARTIFACTID} \|${ODL} :: ${PROJECT} :: ${ARTIFACTID} \)/,/Reactor Summary:/!d;//d" \
63 $CONSOLE_LOG > /tmp/error_msg
65 if [ -z "${PROJECT}" ]; then
68 RELEASE_EMAIL="${RELEASE_EMAIL}, ${PROJECT}-dev@opendaylight.org"
71 SUBJECT="[release] Autorelease ${STREAM} build failure: ${PROJECT}"
73 echo "${BODY}" | mail -a /tmp/error_msg -s "${SUBJECT}" "${RELEASE_EMAIL}"