Skip to content

Instantly share code, notes, and snippets.

@jnbt
Created September 30, 2016 12:51
Show Gist options
  • Save jnbt/0197b3ecddf8a83f054e38eac839563f to your computer and use it in GitHub Desktop.
Save jnbt/0197b3ecddf8a83f054e38eac839563f to your computer and use it in GitHub Desktop.
#!/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