2022-09-23 17:13:22 -04:00
|
|
|
#!/bin/sh
|
2020-10-08 08:08:31 -04:00
|
|
|
# This is based on https://gitlab.com/gitlab-org/gitlab-qa/-/blob/master/bin/slack
|
2020-08-07 17:10:07 -04:00
|
|
|
#
|
|
|
|
# Sends Slack notification MSG to CI_SLACK_WEBHOOK_URL (which needs to be set).
|
|
|
|
# ICON_EMOJI needs to be set to an icon emoji name (without the `:` around it).
|
|
|
|
|
|
|
|
CHANNEL=$1
|
|
|
|
MSG=$2
|
|
|
|
ICON_EMOJI=$3
|
2020-10-08 08:08:31 -04:00
|
|
|
USERNAME=$4
|
2020-08-07 17:10:07 -04:00
|
|
|
|
2020-10-08 08:08:31 -04:00
|
|
|
if [ -z "$CHANNEL" ] || [ -z "$CI_SLACK_WEBHOOK_URL" ] || [ -z "$MSG" ] || [ -z "$ICON_EMOJI" ] || [ -z "$USERNAME" ]; then
|
|
|
|
echo "Missing argument(s) - Use: $0 channel message icon_emoji username"
|
2020-08-07 17:10:07 -04:00
|
|
|
echo "and set CI_SLACK_WEBHOOK_URL environment variable."
|
|
|
|
else
|
2020-10-08 08:08:31 -04:00
|
|
|
curl -X POST --data-urlencode 'payload={"channel": "#'"$CHANNEL"'", "username": "'"$USERNAME"'", "text": "'"$MSG"'", "icon_emoji": "'":$ICON_EMOJI:"'"}' "$CI_SLACK_WEBHOOK_URL"
|
2020-08-07 17:10:07 -04:00
|
|
|
fi
|