Skip to content

Instantly share code, notes, and snippets.

@freibuis
Created November 10, 2015 03:13
Show Gist options
  • Save freibuis/a4323baa193351bdbefe to your computer and use it in GitHub Desktop.
Save freibuis/a4323baa193351bdbefe to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#######################################################################
##
#
# Basic Slack notifier
#
# Author: Freibuis
# Web: https://github.com/freibuis
# Inspiration: The Internet!
# Api Information: https://api.slack.com/incoming-webhooks
#
# Change slack details as needed
# This can be modified to take arguments if neeed.
# example:
# MESSAGE=$1
# SLACK_CHANNEL=$2
#
##
#######################################################################
SLACK_HOSTNAME="yourcompany.slack.com"
SLACK_CHANNEL="#channel-to-post-to"
SLACK_BOTNAME="mybotname-bot"
SLACK_WEBHOOK_API="https://hooks.slack.com/services/000000000/1111111111111111111111111111111111"
MESSAGE="Test message to send to slack"
slack_notify() {
curl -X POST \
--data "payload={\"channel\": \"${SLACK_CHANNEL}\", \"username\": \"${SLACK_BOTNAME}\", \"text\": \"$MESSAGE \"}" \
$SLACK_WEBHOOK_API
}
slack_notify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment