Skip to content

Post-deploy notifications on EngineYard Cloud

Post-deploy notifications on Engine Yard cloud

I’ve got a project hosted on EngineYard‘s cloud servers, with geographically-dispersed team. The developers are often working on separate feature sets, often deployed independently. As a quality-control and awareness measure we wanted to be notified when a deploy was done.

This was pretty easy to set up, and would work with capistrano deployments also.

First we set up a mailer action; I used an existing mailer class for this but you might want to create a separate class just for process-type notifications:

  def deploy_notification(attribs)
    subject       "A build of my_project was deployed to #{attribs[:env_name]}"
    from          "MyProject CodeMonkey HQ"
    @from =       ""
    recipients    ""
    body          :revision => attribs[:revision], :env_name => attribs[:env_name]

and the corresponding deploy_notification.text.plain.erb:

  Heads up code monkeys! New code has been deployed to <%= @env_name %>


  Environment: <%= @env_name %>
  Revision: <%= @revision %>

I’ll probably make that a little fancier with a direct link to the commit on the githubs, and possibly pull in the commit message etc.

Next, we add a rake task to call the mailer; I put this in /lib/tasks/deploy.rake:

  namespace :deploy do
    desc "notify developers of deployment"
    task :notify => :environment do
      attribs = {}
      ARGV.each do |arg|
        if arg.match(/TO=(.*)/)
          attribs[:env_name] = $1
        elsif arg.match(/REVISION=(.*)/)
          attribs[:revision] = $1

Finally, for engineyard integration, in deploy/after_restart.rb:

  # notify dev team of deploy
  run "cd #{release_path} && rake deploy:notify TO=#{@configuration[:environment]} REVISION=#{@configuration[:revision]}"

That gets called by the engineyard chef scripts after the deploy finishes. For capistrano deployments, you could do the same in an “after deploy:restart” call.

That’s it. Hope it’s helpful.

Post a Comment

Your email is never published nor shared. Required fields are marked *