Fork me on GitHub

Kernow Soul

Ruby, Rails and JavaScript Consultant

Vlad the Deployer Hoptoad Integration

| Comments

I’ve just had to setup Hoptoad for one of our apps that uses Vlad for deployment, the integration isn’t quite as easy as with Capistrano. I couldn’t find much information on how to integrate the two so I thought I’d share my solution.

The original Hoptoad task for use with Capistrano needed a little modification.

1
2
3
4
5
6
7
8
task :notify_hoptoad do
  rails_env = fetch(:rails_env, "production")
  local_user = ENV['USER'] || ENV['USERNAME']
  notify_command = "rake hoptoad:deploy TO=#{rails_env} REVISION=#{current_revision} REPO=#{repository} USER=#{local_user}"
  puts "Notifying Hoptoad of Deploy (#{notify_command})"
  `#{notify_command}`
  puts "Hoptoad Notification Complete."
end

fetch is a Capistrano method so needed to be removed, we can use the Vlad environment pattern for this. I also wanted to use the git information for the user instead of the system user, finally as far as I can tell the git commit SHA being deployed is not available in Vlad.

In the Vlad deployment script I added a Hoptoad task to replace the default Capistrano task provided by Hoptoad.

1
2
3
4
5
6
task :notify_hoptoad => [:git_user, :git_revision] do
  notify_command = "rake hoptoad:deploy TO=#{rails_env} REVISION=#{current_sha} REPO=#{repository} USER='#{current_user}'"
  puts "Notifying Hoptoad of Deploy (#{notify_command})"
  `#{notify_command}`
  puts "Hoptoad Notification Complete."
end

Then added it as a dependency for the deploy task

1
task :deploy => [:update, :migrate, :start_app, :notify_hoptoad]

There are a couple of helper tasks I’ve added to get the git user and the SHA of the commit being deployed

1
2
3
4
5
6
7
remote_task :git_revision do
  set :current_sha, run("cd #{File.join(scm_path, 'repo')}; git rev-parse origin/master").strip
end

task :git_user do
  set :current_user, `git config --get user.name`.strip
end

Comments