Skip to content

Instantly share code, notes, and snippets.

@janeczku
Created August 28, 2015 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janeczku/24ced51b05a70347f4ba to your computer and use it in GitHub Desktop.
Save janeczku/24ced51b05a70347f4ba to your computer and use it in GitHub Desktop.
Slack notifications via Curl
#!/bin/bash
function post_to_slack () {
# format message as a code block ```${msg}```
SLACK_MESSAGE="\`\`\`$1\`\`\`"
SLACK_URL=https://hooks.slack.com/services/your-service-identifier-part-here
case "$2" in
INFO)
SLACK_ICON=':slack:'
;;
WARNING)
SLACK_ICON=':warning:'
;;
ERROR)
SLACK_ICON=':bangbang:'
;;
*)
SLACK_ICON=':slack:'
;;
esac
curl -X POST --data "payload={\"text\": \"${SLACK_ICON} ${SLACK_MESSAGE}\"}" ${SLACK_URL}
}
post_to_slack "Hello, World" "INFO"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment