X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Fautorelease%2Fnotify-build-failure.sh;h=805a1fa8f093581af20532149440ddc4d3175d0b;hb=88acf985a358325f372ad6b4ca23d0662ac157c9;hp=e17ce7f843dce3827ab81d3f66514b8352b26f13;hpb=417035461954a2a53ae3c2c3037042cc92592f75;p=releng%2Fbuilder.git diff --git a/jjb/autorelease/notify-build-failure.sh b/jjb/autorelease/notify-build-failure.sh index e17ce7f84..805a1fa8f 100644 --- a/jjb/autorelease/notify-build-failure.sh +++ b/jjb/autorelease/notify-build-failure.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -l # SPDX-License-Identifier: EPL-1.0 ############################################################################## # Copyright (c) 2017 The Linux Foundation and others. @@ -11,6 +11,8 @@ # This script parses the console log to discover which project has caused a # build failure and notify the project as appropriate. +echo "---> notify-build-failure.sh" + NEWLINE=$'\n' RELEASE_EMAIL="release@lists.opendaylight.org" ARCHIVES_DIR="$JENKINS_HOSTNAME/$JOB_NAME/$BUILD_NUMBER" @@ -36,9 +38,11 @@ REACTOR_INFO=$(awk '/Reactor Summary:/ { flag=1 } # check for project format if [[ ${REACTOR_INFO} =~ .*::*.*::*. ]]; then # extract project and artifactId from full format - ODL=$(echo "${REACTOR_INFO}" | awk -F'::' '{ gsub(/^[ \t]+|[ \t]+$/, "", $1); print $1 }') - PROJECT_=$(echo "${REACTOR_INFO}" | awk -F'::' '{ gsub(/^[ \t]+|[ \t]+$/, "", $2); print $2 }') - NAME=$(echo "${REACTOR_INFO}" | awk -F'::' '{ gsub(/^[ \t]+|[ \t]+$/, "", $3); print $3 }') + # Ex: REACTOR_INFO="ODL::sfc::odl-sfc-pot-netconf-renderer 072 " is broken down into + # NAME="ODL", PROJECT_="sfc" and NAME="odl-sfc-pot-netconf-renderer" + ODL=$(echo "${REACTOR_INFO}" | awk -F'::' '{ gsub(/^[ \t]+|[ \t]+[0-9]+[ \t]+$|[ \t]+$/, "", $1); print $1}') + PROJECT_=$(echo "${REACTOR_INFO}" | awk -F'::' '{ gsub(/^[ \t]+|[ \t]+[0-9]+[ \t]+$|[ \t]+$/, "", $2); print $2}') + NAME=$(echo "${REACTOR_INFO}" | awk -F'::' '{ gsub(/^[ \t]+|[ \t]+[0-9]+[ \t]+$|[ \t]+$/, "", $3); print $3}') else # set project from partial format ODL="" @@ -56,7 +60,7 @@ ARTIFACT_ID=$(awk -F: '/\[ERROR\].*mvn -rf :/ { print $2}' $CONSOLE_LOG) # project.groupId is not set but IS inherited from project.parent.groupId # else # exclude project mailing list -if [ ! -z "$ARTIFACT_ID" ]; then +if [ -n "$ARTIFACT_ID" ]; then grouplist=() while IFS="" read -r p; do GROUP=$(xmlstarlet sel\ @@ -68,7 +72,8 @@ if [ ! -z "$ARTIFACT_ID" ]; then -v "/x:project/x:parent/x:groupId"\ --else -o ""\ "$p" 2>/dev/null) - if [ ! -z "${GROUP}" ]; then + if [ -n "${GROUP}" ]; then + # shellcheck disable=SC2207 grouplist+=($(echo "${GROUP}" | awk -F'.' '{ print $3 }')) fi done < <(find . -name "pom.xml") @@ -78,11 +83,11 @@ if [ ! -z "$ARTIFACT_ID" ]; then elif [ "${#grouplist[@]}" -gt 1 ]; then GROUPLIST="NOTE: The artifactId: $ARTIFACT_ID matches multiple groups: ${grouplist[*]}" else - echo "Failed to determine project.groupId using xpaths" + echo "Unable to determine project.groupId using xpaths" fi else - echo "Failed to determine ARTIFACT_ID" - exit 1 + echo "Unable to determine failed ARTIFACT_ID. Build likely successful or bug in this script." + exit 0 fi # Construct email subject & body @@ -102,7 +107,7 @@ Autorelease $STREAM failed to build $ARTIFACT_ID$PROJECT_STRING in build $BUILD_NUMBER. \${!ATTACHMENT} ${PROJECT:+${NEWLINE}${GROUPLIST}} Console Logs: -https://logs.opendaylight.org/$SILO/$ARCHIVES_DIR +https://s3-logs.opendaylight.org/logs/$SILO/$ARCHIVES_DIR Jenkins Build: $BUILD_URL @@ -117,7 +122,8 @@ ODL releng/autorelease team BUILD_STATUS=$(awk '/\[INFO\] Remote staging finished/{flag=1;next}/Total time:/{flag=0}flag' $CONSOLE_LOG \ | grep '\] BUILD' | awk '{print $3}') -if ([ ! -z "${NAME}" ] || [ ! -z "${ARTIFACT_ID}" ]) && [[ "${BUILD_STATUS}" != "SUCCESS" ]]; then +# shellcheck disable=SC2235 +if ([ -n "${NAME}" ] || [ -n "${ARTIFACT_ID}" ]) && [[ "${BUILD_STATUS}" != "SUCCESS" ]]; then # project search pattern should handle both scenarios # 1. Full format: ODL :: $PROJECT :: $ARTIFACT_ID # 2. Partial format: Building $ARTIFACT_ID @@ -125,24 +131,24 @@ if ([ ! -z "${NAME}" ] || [ ! -z "${ARTIFACT_ID}" ]) && [[ "${BUILD_STATUS}" != $CONSOLE_LOG | gzip > "$ERROR_LOG" if [ -n "${PROJECT}" ]; then - RELEASE_EMAIL="\${RELEASE_EMAIL}, \${PROJECT}-dev@lists.opendaylight.org" + RELEASE_EMAIL="${RELEASE_EMAIL}, ${PROJECT}-dev@lists.opendaylight.org" fi file_size=$(du -k "$ERROR_LOG" | cut -f1) - PARAMS=("-r \"Jenkins \"") - PARAMS+=("-s \"$SUBJECT\"") # Only send emails in production (releng), not testing (sandbox) if [ "${SILO}" == "releng" ]; then if [[ "$file_size" -gt 100 ]]; then # shellcheck disable=SC2034 ATTACHMENT=ATTACHMENT_EXCLUDE + eval echo \""${BODY}"\" | mail \ + -r "Jenkins " \ + -s "${SUBJECT}" "${RELEASE_EMAIL}" else - PARAMS+=("-a \"$ERROR_LOG\"") + eval echo \""${BODY}"\" | mail -a "$ERROR_LOG" \ + -r "Jenkins " \ + -s "${SUBJECT}" "${RELEASE_EMAIL}" fi - - eval echo \""${BODY}"\" | eval mail "${PARAMS[*]}" "${RELEASE_EMAIL}" - elif [ "${SILO}" == "sandbox" ]; then echo "Running in sandbox, not actually sending notification emails" echo "Subject: ${SUBJECT}"