Created
September 30, 2016 12:51
-
-
Save jnbt/0197b3ecddf8a83f054e38eac839563f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
MATTERMOST_API="FILL-IN-MATTERMOST-ENDPOINT" | |
MATTERMOST_TOKEN="FILL-IN-INTEGRATION-TOKEN" | |
MATTERMOST_USERNAME="AN-USERNAME" | |
MATTERMOST_ICON="AN-URL-TO-AN-IMAGE" | |
die() { | |
echo >&2 "$@" | |
exit 1 | |
} | |
[ "$#" -eq 2 ] || die "Usage: mattermost.sh CHANNEL_NAME MESSAGE" | |
channel=$1 | |
message=$2 | |
url="$MATTERMOST_API/$MATTERMOST_TOKEN" | |
payload="{ \ | |
\"text\": \"$message\", \ | |
\"channel\": \"$channel\", \ | |
\"username\": \"$MATTERMOST_USERNAME\", \ | |
\"icon_url\": \"$MATTERMOST_ICON\" \ | |
}" | |
curl -X POST --silent --show-error --output /dev/null -d "payload=$payload" $url || true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment