From 2292283dca4a2c525d9d93c99a605f926e93585a Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Mon, 10 Jun 2019 16:01:26 -0300 Subject: Send logs via email after finishing provision.sh The email will be send for both sucessfull and failed runs. --- scripts/ci/mail.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 scripts/ci/mail.sh (limited to 'scripts/ci/mail.sh') diff --git a/scripts/ci/mail.sh b/scripts/ci/mail.sh new file mode 100755 index 0000000..d15c5db --- /dev/null +++ b/scripts/ci/mail.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -Eeuo pipefail +cd "$(dirname "${BASH_SOURCE[0]}")" +cd ../../ + +VPS_COMMIT_SHA="${1:-}" +[[ -z "${VPS_COMMIT_SHA}" ]] && { + echo 'Error: missing $VPS_COMMIT_SHA positional argument.' + exit 2 +} + +SUBJECT="VPS CI run #${JOB_ID} logs" +ATTACHMENT_PATH='logs.txt' +BODY=$(cat < "${ATTACHMENT_PATH}" + +curl "${MAILGUN_URL}" \ + -s \ + --user "${MAILGUN_USER}" \ + -F from="${MAILGUN_FROM}" \ + -F to="${MAILGUN_TO}" \ + -F subject="${SUBJECT}" \ + -F text="${BODY}" \ + -F attachment="@${ATTACHMENT_PATH}" -- cgit v1.2.3