Created
July 24, 2018 10:06
-
-
Save Voronenko/cfaaf27b7e5056bc3356e7c4b5e1f32c to your computer and use it in GitHub Desktop.
Simple slack integration test using curl
This file contains hidden or 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/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