Tags
Archive
Sites I Like
October 5th, 5:28am
0 comments
Campfire SVN and email notification
Here's a quick way to add Subversion notification for Campfire using Tinder.
Create svn-campfire.rb with the correct username and password:
#!/usr/local/bin/rubyrequire 'rubygems'require 'tinder'svnlook = "/usr/local/bin/svnlook"campfire = Tinder::Campfire.new 'campfiresubdomain'campfire.login 'user@example.com', 'password'room = campfire.find_room_by_name('room name')room.joinif ARGV.size > 1 revision = ARGV[1] path = ARGV[0] # we're using this for multiple svn repos so parse the project name from the path project = ARGV[0].gsub("/home/user/svn/", '') author = `#{svnlook} author -r #{revision} #{path}` paths = `#{svnlook} changed -r #{revision} #{path}` log = `#{svnlook} log -r #{revision} #{path}` message = [log,paths].join("\n").strip url = "Changeset \##{revision} by #{author} (http://trac.domain.com/trac/#{project}/changeset/#{revision})" room.speak(url) room.paste(message)else room.speak(ARGV[0])endroom.leaveAdd this to your SVN post-commit hook:
/usr/local/bin/ruby /path/to/svn-campfire.rb "$1" "$2"
Here's a quick way to send emails to campfire. Create an email address to use for sending messages to campfire and then create mailer-campfire.rb with your domain, usernames and passwords:
#!/usr/local/bin/rubyrequire 'rubygems'require 'action_mailer'require 'tinder'require 'net/pop'# setup an email address to use for campfireNet::POP3.delete_all("domain.com", nil, "user+domain.com", "password") do |m| campfire = Tinder::Campfire.new 'campfiresubdomain' campfire.login 'user@example.com', 'password' room = campfire.find_room_by_name('room name') room.join begin message = TMail::Mail.parse(m.pop) subject = message.subject if message.subject sender = message.from.first if message.from body = message.body if message.body room.speak("I've received an email from #{sender} with the subject '#{subject}'") room.paste(body) rescue Exception => e end room.leaveendThen create a cron job to fire this off every minute:
* * * * * /usr/local/bin/ruby /home/path/to/mailer-campfire.rb
Next step, create a Jabber gateway for Campfire using Tinder.
