In order to post to our Campfire chat when the CI goes red, we threw the following script in script/campfire_post:
#!/usr/bin/env ruby
require 'rubygems'
require 'net/http'
require 'uri'
require 'json'
url = URI.parse('http://SUBDOMAIN.campfirenow.com/room/ROOM_ID/speak.json')
req = Net::HTTP::Post.new(url.path)
req.basic_auth 'API_KEY', 'X' # leave the X
req.body = JSON.dump({ :message => { :body => ARGV.first }})
req.content_type = 'application/json'
res = Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }
case res
when Net::HTTPSuccess, Net::HTTPRedirection
# OK
else
res.error!
end
And then in cruise.rake:
desc "The task that cruisecontrol.rb runs"
task :cruise do
begin
rake "spec"
# etc
# etc
rescue
exclaim = ["Oh goodness, t", "OMG t", "Look sharp, t", "Attention everyone! T", "Ohnoes! T"][rand * 5]
system "ruby script/campfire_post '#{exclaim}he build just went red!'"
raise
end
end
And it’s even cheeky!
There is a Campfire Notifier plugin for CruiseControl.rb at [http://github.com/thoughtworks/cruisecontrol.rb-contrib/tree/master/plugins/campfire_notifier/](http://github.com/thoughtworks/cruisecontrol.rb-contrib/tree/master/plugins/campfire_notifier/).
I don’t think it’s this cheeky, though.
March 3, 2010 at 11:08 pm