diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-05-21 18:55:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2019-05-21 18:55:22 +0000 |
commit | 61d0027904ee9c040985b1642ca228737d616d03 (patch) | |
tree | c90838c137b4dc4a2de1cff9f2d7be5552d605e7 /tests/installer/slack.sh | |
parent | Adding upstream version 1.14.0. (diff) | |
download | netdata-61d0027904ee9c040985b1642ca228737d616d03.tar.xz netdata-61d0027904ee9c040985b1642ca228737d616d03.zip |
Adding upstream version 1.15.0.upstream/1.15.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/installer/slack.sh')
-rwxr-xr-x | tests/installer/slack.sh | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/installer/slack.sh b/tests/installer/slack.sh new file mode 100755 index 00000000..3c5f94a4 --- /dev/null +++ b/tests/installer/slack.sh @@ -0,0 +1,58 @@ +# #No shebang necessary +# BASH Lib: Simple incoming webhook for slack integration. +# +# The script expects the following parameters to be defined by the upper layer: +# SLACK_NOTIFY_WEBHOOK_URL +# SLACK_BOT_NAME +# SLACK_CHANNEL +# +# Copyright: +# +# Author: Pavlos Emm. Katsoulakis <paul@netdata.cloud + +post_message() { + TYPE="$1" + MESSAGE="$2" + + case "$TYPE" in + "PLAIN_MESSAGE") + curl -X POST --data-urlencode "payload={\"channel\": \"${SLACK_CHANNEL}\", \"username\": \"${SLACK_BOT_NAME}\", \"text\": \"${MESSAGE}\", \"icon_emoji\": \":space_invader:\"}" ${SLACK_NOTIFY_WEBHOOK_URL} + ;; + "TRAVIS_MESSAGE") + EVENT_LINE="${TRAVIS_JOB_NUMBER}: Event type '${TRAVIS_EVENT_TYPE}', on '${TRAVIS_OS_NAME}'" + if [ "$TRAVIS_EVENT_TYPE}" == "pull_request" ]; then + EVENT_LINE="${TRAVIS_JOB_NUMBER}: Event type '${TRAVIS_EVENT_TYPE}' #${TRAVIS_PULL_REQUEST}, on '${TRAVIS_OS_NAME}' " + fi + + POST_MESSAGE="{ + \"text\": \"${TRAVIS_REPO_SLUG}, ${MESSAGE}\", + \"attachments\": [{ + \"text\": \"${TRAVIS_JOB_NUMBER}: Event type '${TRAVIS_EVENT_TYPE}', on '${TRAVIS_OS_NAME}' \", + \"fallback\": \"I could not determine the build\", + \"callback_id\": \"\", + \"color\": \"#3AA3E3\", + \"attachment_type\": \"default\", + \"actions\": [ + { + \"name\": \"${TRAVIS_BUILD_NUMBER}\", + \"text\": \"Build #${TRAVIS_BUILD_NUMBER}\", + \"type\": \"button\", + \"url\": \"${TRAVIS_BUILD_WEB_URL}\" + }, + { + \"name\": \"${TRAVIS_JOB_NUMBER}\", + \"text\": \"Job #${TRAVIS_JOB_NUMBER}\", + \"type\": \"button\", + \"url\": \"${TRAVIS_JOB_WEB_URL}\" + }] + }] + }" + echo "Sending ${POST_MESSAGE}" + curl -X POST --data-urlencode "payload=${POST_MESSAGE}" "${SLACK_NOTIFY_WEBHOOK_URL}" + ;; + *) + echo "Unrecognized message type \"$TYPE\" was given" + return 1 + ;; + esac +} |