From: Anil Belur Date: Tue, 28 Nov 2017 00:45:29 +0000 (+1000) Subject: Use eval command to append mail options X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=ea26afb7d635a615547490e05a7aef2d9bcda265;p=releng%2Fbuilder.git Use eval command to append mail options Use eval to append mail options with the notify script. When the eval command is used without escaping the variables causes wordsplitting. Ref: http://mywiki.wooledge.org/BashFAQ/050 JIRA: RELENG-213 Change-Id: I736f3eaa98d58c4514a936c137d2a2df77053167 Signed-off-by: Anil Belur --- diff --git a/jjb/autorelease/notify-build-failure.sh b/jjb/autorelease/notify-build-failure.sh index 090e80803..e17ce7f84 100644 --- a/jjb/autorelease/notify-build-failure.sh +++ b/jjb/autorelease/notify-build-failure.sh @@ -125,24 +125,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 - eval echo \""${BODY}"\" | mail -a "$ERROR_LOG" \ - -r "Jenkins " \ - -s "${SUBJECT}" "${RELEASE_EMAIL}" + PARAMS+=("-a \"$ERROR_LOG\"") 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}"