Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
67 lines (55 sloc) 1.52 KB
class ProwlNotifier
begin
require "prowler"
rescue LoadError
puts "Prowler gem missing.\nsudo gem install pixeltrix-prowler --source=http://gems.github.com"
raise
end
attr_accessor :keys
attr_accessor :from
def initialize(project = nil)
@keys = []
end
def from
@from || "CruiseControl.rb"
end
def build_broken(build, previous_build)
return if keys.empty?
notify("Build failed",
enhance_description("#{build.project.name} build #{build.label} broken", build),
Prowler::Priority::HIGH)
end
def build_fixed(build, previous_build)
return if keys.empty?
notify("Build fixed",
enhance_description("#{build.project.name} build #{build.label} fixed", build),
Prowler::Priority::NORMAL)
end
private
def notify(event, description, priority = Prowler::Priority::NORMAL)
keys.each do |key|
Prowler.new(key, from).notify(event, description, priority)
end
CruiseControl::Log.event("Sent Prowl notification to #{keys.size == 1 ? "1 person" : "#{keys.size} people"}", :debug)
rescue => e
CruiseControl::Log.event("Error sending prowl notification", :error)
raise
end
def enhance_description(desc, build)
if Configuration.dashboard_url
desc += " See #{short_url(build.url)} for details."
end
desc
end
begin
require "shorturl"
def short_url(url)
ShortURL.shorten(url)
end
rescue LoadError
def short_url(url)
url
end
end
end
Project.plugin :prowl_notifier
Something went wrong with that request. Please try again.