7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/rundock/plugin/hook/slack.rb', line 7
def hook(operation_attributes, log_buffer)
::Slack.configure do |config|
config.token = @contents[:token]
end
@contents[:channel] = '#' + @contents[:channel]
Logger.info("send slack to #{@contents[:channel]} channel")
post_args = @contents.dup.reject {|k, v| k == :token}
out_msg = ''
log_buffer.each do |log|
out_msg += log.formatted_message
end
Logger.debug("post args: #{post_args.to_s}")
post_args[:text] = out_msg
::Slack.chat_postMessage(post_args) unless operation_attributes[0][:dry_run]
end
|