Skip to content

Instantly share code, notes, and snippets.

@nhosoya
Created April 23, 2015 09:44
Show Gist options
  • Select an option

  • Save nhosoya/0b35044c0c0aa3056e2c to your computer and use it in GitHub Desktop.

Select an option

Save nhosoya/0b35044c0c0aa3056e2c to your computer and use it in GitHub Desktop.
Slackに通知するスクリプト
#!/bin/bash
WEBHOOKURL="$1"
MESSAGEFILE=$2
CHANNEL="$3"
BOTNAME="$4"
FACEICON="$5"
TMPFILE=$(mktemp)
cat ${MESSAGEFILE} | tr '\n' '\\' | sed 's/\\/\\n/g' | sed 's/\"/\\\"/g' > ${TMPFILE}
WEBMESSAGE=$(cat ${TMPFILE})
curl -s -S -X POST --data-urlencode "payload={ \
\"channel\": \"${CHANNEL}\", \
\"username\": \"${BOTNAME}\", \
\"icon_emoji\": \"${FACEICON}\", \
\"text\": \"${WEBMESSAGE}\" \
}" ${WEBHOOKURL}
if [ -f "${TMPFILE}" ] ; then
rm -f ${TMPFILE}
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment