Skip to content

Instantly share code, notes, and snippets.

@yyoshiki41
Created January 4, 2017 06:30
Show Gist options
  • Save yyoshiki41/b342c8b62e659536fa910322900c380a to your computer and use it in GitHub Desktop.
Save yyoshiki41/b342c8b62e659536fa910322900c380a to your computer and use it in GitHub Desktop.
require 'net/http'
require 'uri'
require 'json'
resp = JSON.parse($stdin.gets)
if resp["exitCode"] != 0 then
uri = URI.parse("https://hooks.slack.com/services/***")
payload = {
text: "```#{JSON.pretty_generate(resp)}```",
channel: "@yyoshiki41",
username: "Cron job fails",
icon_emoji: ":scream_cat:"
}
Net::HTTP.post_form(uri, { payload: payload.to_json })
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment