Skip to content

Instantly share code, notes, and snippets.

@woodja
Last active December 20, 2015 03:39
Show Gist options
  • Save woodja/6065423 to your computer and use it in GitHub Desktop.
Save woodja/6065423 to your computer and use it in GitHub Desktop.
HipChat notification command, which can be used as part of deploy scripts, test automation, etc.
#!/bin/bash
# Make sure to add your token and room id
# Input is from standard input, so you can run it like
# echo "This is a test" | hipchat_echo.sh
# date | hipcaht_echo.sh
# cat results.log | hipchat_echo.sh
# hipchat_echo.sh
# my quick message ^D
TOKEN={Your room API token}
ROOM_ID={Your room ID}
COLOR=green
FROM=$USER
NOTIFY=1
read MESSAGE
HOST='api.hipchat.com'
INPUT=$(echo -n "${MESSAGE}" | perl -p -e 's/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg')
curl -sS \
-d "auth_token=$TOKEN&room_id=$ROOM_ID&from=$FROM&color=$COLOR&message=$INPUT&notify=$NOTIFY" \
https://$HOST/v1/rooms/message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment