Skip to content

Instantly share code, notes, and snippets.

@q7r
Last active October 26, 2017 09:34
Show Gist options
  • Save q7r/c5e6b7ab8ca66aedaf1f00b29f52f3aa to your computer and use it in GitHub Desktop.
Save q7r/c5e6b7ab8ca66aedaf1f00b29f52f3aa to your computer and use it in GitHub Desktop.
#!/bin/bash
# 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": "bb8", "text": "'"$ERROR_MSG"'", "icon_emoji": ":robot_face:"}' "$CI_SLACK_WEBHOOK_URL"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment