Use eval command to append mail options
[releng/builder.git] / jjb / autorelease / notify-build-failure.sh
index 61651964dab65afe94f41a36d38225761d1a52e6..e17ce7f843dce3827ab81d3f66514b8352b26f13 100644 (file)
@@ -1,5 +1,5 @@
 #!/bin/bash
-# @License EPL-1.0 <http://spdx.org/licenses/EPL-1.0>
+# SPDX-License-Identifier: EPL-1.0
 ##############################################################################
 # Copyright (c) 2017 The Linux Foundation and others.
 #
@@ -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 <jenkins-dontreply@opendaylight.org>\"")
+    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 <jenkins-dontreply@opendaylight.org>" \
-                -s "${SUBJECT}" "${RELEASE_EMAIL}"
         else
-            eval echo \""${BODY}"\" | mail -a "$ERROR_LOG" \
-                -r "Jenkins <jenkins-dontreply@opendaylight.org>" \
-                -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}"