Last active
February 7, 2017 03:32
-
-
Save yyoshiki41/6ed320204703458967d3ae69c729928f to your computer and use it in GitHub Desktop.
httpリクエストにSSLを使わないと失敗する場合
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
| #!/usr/bin/ruby | |
| 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/***") | |
| req = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'}) | |
| req.body = { | |
| text: "```#{JSON.pretty_generate(resp)}```", | |
| channel: "@yyoshiki41", | |
| username: "Cron job fails", | |
| icon_emoji: ":scream_cat:" | |
| }.to_json | |
| http = Net::HTTP.new(uri.host, uri.port) | |
| http.use_ssl = true | |
| http.verify_mode = OpenSSL::SSL::VERIFY_NONE | |
| http.request(req) | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/yyoshiki41/b342c8b62e659536fa910322900c380a