eddorre

Introducing Envoy – Deployment Messaging Ruby Gem

A little while ago, Robby Russell looked up from his monitor and said, “I wish we could get notified in Campfire whenever someone starts and is finishes with a deployment. I think you should write that.” I nodded in agreement and responded, “yeah someday”, and then went back to the client work at hand.

I found myself with some free time on my hands on a weekend and I started working on a gem that would do this for us. A couple of iterations later, some time for user testing and I’m happy to introduce my first Ruby gem titled Envoy.

Using my gem, you can easily send messages to Campfire, Email or a Web hooks url. We’ve been using it for a few months and it’s fit the bill quite nicely.

Here is a sample of how you can use it in your own Capistrano scripts:


begin
  require 'envoy'
  set :envoy_loaded, true
rescue LoadError
  set :envoy_loaded, false
end

if envoy_loaded
  set :messenger, Envoy::Messenger.new
  set :git_username, `git config user.name`.gsub("\n", '')
  messenger.transport :name => :campfire, :account => [YOUR ACCOUNT HERE], :token => [YOUR TOKEN HERE], :use_ssl => true
else
  set :messenger, nil
end

before :deploy do
  if messenger
    messenger.message :name => :start_deployment,
      :subject => "#{git_username} started deployment of branch master to production for project Foo at #{Time.now}"
    messenger.deliver_start_deployment
  end
end

after :deploy do
  if messenger
    messenger.message :name => :end_deployment,
      :subject => "#{git_username} ended deployment of branch master to production for project Foo at #{Time.now}"
    messenger.deliver_end_deployment
  end
end


Comments

Comments are closed

Comments are closed on this post. If you have something on your mind regarding this post, don't hesitate to drop me a line.