5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/opbeat/capistrano/capistrano2.rb', line 5
def self.load_into(configuration)
configuration.load do
after "deploy", "opbeat:notify"
after "deploy:migrations", "opbeat:notify"
after "deploy:cold", "opbeat:notify"
namespace :opbeat do
desc "Notifies Opbeat of new deployments"
task :notify, :except => { :no_release => true } do
scm = fetch(:scm)
if scm.to_s != "git"
puts "Skipping Opbeat deployment notification because scm is not git."
next
end
branches = capture("cd #{current_release}; /usr/bin/env git branch --contains #{current_revision}").split
if branches.length == 1
branch = branch[0].sub("* ")
else
branch = nil
end
notify_command = "cd #{current_release}; REV=#{current_revision} "
notify_command << "BRANCH=#{branch} " if branch
rails_env = fetch(:rails_env, "production")
notify_command << "RAILS_ENV=#{rails_env} "
executable = fetch(:rake, 'bundle exec rake ')
notify_command << "#{executable} opbeat:deployment"
capture notify_command, :once => true
end
end
end
end
|