Tinder Continuous Integration to Campfire Script
November 30th, 2007 by pyrat
Recently signal vs noise showcased how their continuous integration tool posts to campfire using the tinder api. Well I thought that it looked cool so have thrown together a quick and dirty ruby script to do it as well.
It will integrate with anything which has an RSS feed. Cruisecontrol.rb does and works nicely. Its a bit rough around the edges but works as is. Run it from the crontab and you are sorted.
Improvements welcome.
Here is a screenshot of it posting on campfire:

Here is the code:
#!/usr/bin/ruby require 'rubygems' require 'active_record' require 'simple-rss' require 'open-uri' require 'tinder' include Tinder # Author: Alastair Brunton # http://www.simplyexcited.co.uk # Rss to Campfire campfire_domain = 'simplyexcited' campfire_email = 'cheer@cheerfactory.co.uk' campfire_password = 'xxxx' feeds = %w(http://feedserver/edflats.rss) ActiveRecord::Base.logger = Logger.new(STDERR) ActiveRecord::Base.colorize_logging = false ActiveRecord::Base.establish_connection( :adapter => "mysql", :username => "username", :password => "password", :database => "ci_to_campfire" ) # uncomment this section the first time to create the table # ActiveRecord::Schema.define do # create_table :items do |table| # table.column :feed_identifier, :string # table.column :title, :string # table.column :link, :string # table.column :description, :text # end # end class Item < ActiveRecord::Base def to_s %(Theres been some action:\n #{self.title}\n\n #{self.description} ) end end campfire = Campfire.new campfire_domain campfire.login campfire_email, campfire_password room = campfire.find_room_by_name('The Office') feeds.each do |rss_url| rss_user_agent = "RSS to Campfire" rss_items = SimpleRSS.parse open(rss_url ,"User-Agent" => rss_user_agent) for item in rss_items.items Item.transaction do unless existing_item = Item.find(:all, :conditions => ["link=? AND feed_identifier=?", item.link, rss_url]).first new_item = Item.create(:title => item.title, :link => item.link, :description => item.description, :feed_identifier => rss_url) room.paste(new_item.to_s) end end end end room.leave campfire.logout



