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:-"OpenDaylight"}-devs,
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}/Total time:/{flag=0}flag' $CONSOLE_LOG \
67 | grep '\] BUILD' | awk '{print $3}')
69 if [ ! -z "${ARTIFACTID}" ] && [[ "${BUILD_STATUS}" != "SUCCESS" ]]; then
70 # project search pattern should handle both scenarios
71 # 1. Full format: ODL :: $PROJECT :: $ARTIFACTID
72 # 2. Partial format: Building $ARTIFACTID
73 sed -e "/\[INFO\] Building \(${ARTIFACTID} \|${ODL} :: ${PROJECT} :: ${ARTIFACTID} \)/,/Reactor Summary:/!d;//d" \
74 $CONSOLE_LOG > /tmp/error.txt
76 if [ -n "${PROJECT}" ]; then
77 RELEASE_EMAIL="${RELEASE_EMAIL}, ${PROJECT}-dev@lists.opendaylight.org"
80 # Only send emails in production (releng), not testing (sandbox)
81 if [ "${SILO}" == "releng" ]; then
82 echo "${BODY}" | mail -a /tmp/error.txt \
83 -r "Jenkins <jenkins-dontreply@opendaylight.org>" \
84 -s "${SUBJECT}" "${RELEASE_EMAIL}"
85 elif [ "${SILO}" == "sandbox" ]; then
86 echo "Running in sandbox, not actually sending notification emails"
87 echo "Subject: ${SUBJECT}"
90 echo "Not sure how to notify in \"${SILO}\" Jenkins silo"