27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/hipchat-chef/chef.rb', line 27
def report
unless @excluded_envs.include?(node.chef_environment)
msg = if run_status.failed? then "Failure on \"<b>#{node.name}</b>\" (<b>#{node.chef_environment}</b>, <b>#{node['ipaddress']}</b>):\n#{run_status.formatted_exception}"
elsif run_status.success? && @report_success
"Chef run on \"#{node.name}\" completed in #{run_status.elapsed_time.round(2)} seconds"
else nil
end
@override_colors.default_proc = proc do |h, k|
case k
when String then sym = k.to_sym; h[sym] if h.key?(sym)
when Symbol then str = k.to_s; h[str] if h.key?(str)
end
end
color = if run_status.success?
@override_colors[:success].to_s || 'green'
else
@override_colors[:failure].to_s || 'red'
end
if msg
client = HipChat::Client.new(@api_token)
client[@room_name].send('Chef', msg, :notify => @notify_users, :color => color)
end
end
end
|