Here’s a simple builder plugin that you can use to make CruiseControl.rb post to Campfire when it starts a new build (showing the build messages), and when the build finishes.
I’ve stripped this down to be as simple as possible.
require 'rubygems'
require 'tinder'
class CampfireNotifier
attr_accessor :subdomain, :username, :password, :room_name
def initialize(project = nil)
end
def room
@campfire ||= Tinder::Campfire.new(subdomain, :ssl => false) # SSL's not working as of tinder 0.17 on 2008-01-28
@campfire.login(username, password) unless @campfire.logged_in?
@room ||= @campfire.find_room_by_name(room_name)
end
def speak(message, options = {})
room.join(true) # we get booted off after a while :/
room.speak(message, options)
rescue Exception => e
CruiseControl::Log.error("Couldn't say '#{message}' in '#{room_name}': '#{e.message}'")
@campfire = @room = nil
end
def new_revisions_detected(new_revisions)
speak new_revisions.to_s, :paste => true
end
def build_finished(build)
if build.failed?
speak("Build #{build.label} of #{build.project.name} failed; see #{build.url}")
else
speak("Build #{build.label} of #{build.project.name} succeeded")
end
end
end
Project.plugin(CampfireNotifier)
Put this in lib/builder_plugins (or on older versions of CruiseControl.rb, in builder_plugins/installed).
Comments