gitlab-org--gitlab-foss/scripts/notify_slack.sh
Elan Ruusamäe 4e90f1009d use plain shell
no bashism detected here
2016-04-03 13:44:32 +00:00

13 lines
No EOL
524 B
Bash
Executable file

#!/bin/sh
# Sends Slack notification ERROR_MSG to CHANNEL
# An env. variable CI_SLACK_WEBHOOK_URL needs to be set.
CHANNEL=$1
ERROR_MSG=$2
if [ -z "$CHANNEL" ] || [ -z "$ERROR_MSG" ] || [ -z "$CI_SLACK_WEBHOOK_URL" ]; then
echo "Missing argument(s) - Use: $0 channel message"
echo "and set CI_SLACK_WEBHOOK_URL environment variable."
else
curl -X POST --data-urlencode 'payload={"channel": "'"$CHANNEL"'", "username": "gitlab-ci", "text": "'"$ERROR_MSG"'", "icon_emoji": ":gitlab:"}' "$CI_SLACK_WEBHOOK_URL"
fi