Sha256: ef134b4da886f8ba2a6fdca3588289cb7426984ad0adc646090ce7a6d905a635
Contents?: true
Size: 903 Bytes
Versions: 7
Compression:
Stored size: 903 Bytes
Contents
#!/usr/bin/env ruby require 'rest-client' require 'json' require_relative '../lib/pivotoolz/post_slack_message' URL = ENV.fetch('SLACK_WEBHOOK_URL') { '' } CHANNEL_URL_MAP = ENV.fetch('SLACK_WEBHOOK_CHANNEL_URLS') { {} } if URL.empty? && CHANNEL_URL_MAP.empty? puts "Need either SLACK_WEBHOOK_URL or SLACK_WEBHOOK_CHANNEL_URLS to be defined!" exit 0 end channel = ARGV.shift if channel.to_s.empty? puts "Channel to post to is required!!" exit 0 end content = ARGV.empty? ? ARGF.read : StringIO.new(ARGV.join("\n")).read exit 0 if content.strip.empty? psm = PostSlackMessage.new webhook_url = psm.select_webhook_url(URL, CHANNEL_URL_MAP, channel) if webhook_url.nil? puts "Channel '#{channel}' webhook url not found! Please define it in SLACK_WEBHOOK_CHANNEL_URLS environment variable" exit 0 end result = psm.post_message(webhook_url, channel, content) puts result if !result.empty?
Version data entries
7 entries across 7 versions & 1 rubygems