This commit is contained in:
Gary Hansen
2017-06-21 01:14:01 +00:00
parent 14449d3f3f
commit bae393d94e

37
slackecho Normal file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
# send message to slack
#
# $1 message
# $2 username - optional
# $3 channel - optional
# $4 icon - optional
if [ "$1" = "" ]; then
echo "send message to slack"
echo "slackecho <message> [username] [channel] [icon]"
exit
fi
SLACKURL="https://hooks.slack.com/services/YOURURL"
#Setup defaults
if [ "$2" = "" ]; then
SLACKUSER="git-deploy"
else
SLACKUSER="$2"
fi
if [ "$3" = "" ]; then
SLACKCH="devops"
else
SLACKCH="$3"
fi
if [ "$4" = "" ]; then
SLACKICON=":robot_face:"
else
SLACKICON="$4"
fi
#build the post form and send it to the slack url
curl -X POST --data-urlencode 'payload={"channel": "#'$SLACKCH'", "username": "'$SLACKUSER'", "text": "'"$1"'", "icon_emoji": "'$SLACKICON'"}' $SLACKURL -o /dev/null >/dev/null 2>&1