Skip to content

Instantly share code, notes, and snippets.

@nesheep5
Created March 30, 2018 03:13
Show Gist options
  • Select an option

  • Save nesheep5/b6df210c84d88c4793b9c074023022fa to your computer and use it in GitHub Desktop.

Select an option

Save nesheep5/b6df210c84d88c4793b9c074023022fa to your computer and use it in GitHub Desktop.
require 'net/http'
require 'uri'
require 'json'
# slack通知
# 事前準備 slackの通知したいチャンネルにincoming webhooksアプリを入れ、webhook urlを取得
# 実行方法
# ruby slack_notify.rb 'https://hooks.slack.com/services/XXXXX/YYYYY/ZZZZZ' 'hello!!'
url = ARGV[0]
msg = ARGV[1]
data = {
username: '#deploy-bot',
icon_emoji: ':sushi:',
text: msg
}
res = Net::HTTP.post_form(URI.parse(url), {payload: data.to_json})
puts res.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment