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 Hoptaod task for use with Capistrano needed a little modification.
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.
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
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
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