Correctly fix handling of CI Slack notifications. (#9902)
Austin S. Hemmelgarn committed
Sep 9, 2020 at 12:44 UTC
10728c2e6e6d96c077716e5cf222d6fc408319cd
2 files changed
+5
-8
.travis.yml
-3
@@ -42,9 +42,6 @@ notifications:
42
webhooks:
43
urls:
44
- https://app.fossa.io/hooks/travisci
45
- if: branch = master
46
- slack:
47
- if: branch = master
45
46
# Define the stage sequence and conditionals
47
#
tests/installer/slack.sh
+5
-5
@@ -1,6 +1,6 @@
1
# #No shebang necessary
2
# BASH Lib: Simple incoming webhook for slack integration.
3
-#
3
+#
4
# The script expects the following parameters to be defined by the upper layer:
5
# SLACK_NOTIFY_WEBHOOK_URL
6
# SLACK_BOT_NAME
@@ -17,12 +17,12 @@ post_message() {
17
18
case "$TYPE" in
19
"PLAIN_MESSAGE")
20
- curl -X POST --data-urlencode "payload={\"channel\": \"${SLACK_CHANNEL}\", \"username\": \"${SLACK_BOT_NAME}\", \"text\": \"${MESSAGE}\", \"icon_emoji\": \":space_invader:\"}" ${SLACK_NOTIFY_WEBHOOK_URL}
20
+ curl -X POST --data-urlencode "payload={\"channel\": \"${SLACK_CHANNEL}\", \"username\": \"${SLACK_BOT_NAME}\", \"text\": \"${MESSAGE}\", \"icon_emoji\": \":space_invader:\"}" "${SLACK_NOTIFY_WEBHOOK_URL}"
21
;;
22
"TRAVIS_MESSAGE")
23
- EVENT_LINE="${TRAVIS_JOB_NUMBER}: Event type '${TRAVIS_EVENT_TYPE}', on '${TRAVIS_OS_NAME}'"
24
- if [ "$TRAVIS_EVENT_TYPE}" == "pull_request" ]; then
25
- EVENT_LINE="${TRAVIS_JOB_NUMBER}: Event type '${TRAVIS_EVENT_TYPE}' #${TRAVIS_PULL_REQUEST}, on '${TRAVIS_OS_NAME}' "
23
+ if [ "${TRAVIS_EVENT_TYPE}" == "pull_request" ] || [ "${TRAVIS_BRANCH}" != "master" ] ; then
24
+ echo "Skipping notification due to build type."
25
+ return 0
26
fi
27
28
if [ -n "${CUSTOM_CHANNEL}" ]; then