Sha256: 4248baeff0282cc277fe597f53c94dda5ea599ea462417b8e4e404acfe7d5108

Contents?: true

Size: 1.44 KB

Versions: 12

Compression:

Stored size: 1.44 KB

Contents

require 'capistrano'

module Opbeat
  module Capistrano
    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
  end
end

if Capistrano::Configuration.instance
  Opbeat::Capistrano.load_into(Capistrano::Configuration.instance)
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
kuende-opbeat-2.0.4 lib/opbeat/capistrano/capistrano2.rb
kuende-opbeat-2.0.3 lib/opbeat/capistrano/capistrano2.rb
kuende-opbeat-2.0.2 lib/opbeat/capistrano/capistrano2.rb
kuende-opbeat-2.0.1 lib/opbeat/capistrano/capistrano2.rb
opbeat-2.0.0 lib/opbeat/capistrano/capistrano2.rb
opbeat-1.1.1 lib/opbeat/capistrano/capistrano2.rb
opbeat-1.1.0 lib/opbeat/capistrano/capistrano2.rb
opbeat-1.0.0 lib/opbeat/capistrano/capistrano2.rb
opbeat-0.9.2 lib/opbeat/capistrano/capistrano2.rb
opbeat-0.9.1 lib/opbeat/capistrano/capistrano2.rb
opbeat-0.9.0 lib/opbeat/capistrano/capistrano2.rb
opbeat-0.8.0 lib/opbeat/capistrano/capistrano2.rb