Correctly fix handling of CI Slack notifications. (#9902)

This commit is contained in:
Austin S. Hemmelgarn 2020-09-09 12:44:32 -04:00 committed by GitHub
parent 3e0661a2af
commit 10728c2e6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 8 deletions

View File

@ -42,9 +42,6 @@ notifications:
webhooks:
urls:
- https://app.fossa.io/hooks/travisci
if: branch = master
slack:
if: branch = master
# Define the stage sequence and conditionals
#

View File

@ -1,6 +1,6 @@
# #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
@ -17,12 +17,12 @@ post_message() {
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}
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}' "
if [ "${TRAVIS_EVENT_TYPE}" == "pull_request" ] || [ "${TRAVIS_BRANCH}" != "master" ] ; then
echo "Skipping notification due to build type."
return 0
fi
if [ -n "${CUSTOM_CHANNEL}" ]; then