Module: Bugsnag::Capistrano

Defined in:
lib/bugsnag/capistrano2.rb

Class Method Summary collapse

Class Method Details

.load_into(configuration) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bugsnag/capistrano2.rb', line 3

def self.load_into(configuration)
  configuration.load do
    after "deploy",            "bugsnag:deploy"
    after "deploy:migrations", "bugsnag:deploy"

    namespace :bugsnag do
      desc "Notify Bugsnag that new production code has been deployed"
      task :deploy, :except => { :no_release => true }, :on_error => :continue do
        begin
          Bugsnag::Deploy.notify({
            :api_key => fetch(:bugsnag_api_key, ENV["BUGSNAG_API_KEY"]),
            :release_stage => fetch(:rails_env, ENV["BUGSNAG_RELEASE_STAGE"] || "production"),
            :revision => fetch(:current_revision, ENV["BUGSNAG_REPOSITORY"]),
            :repository => fetch(:repository, ENV["BUGSNAG_REVISION"]),
            :branch => fetch(:branch, ENV["BUGSNAG_BRANCH"],
            :app_version => fetch(:app_version, ENV["BUGSNAG_APP_VERSION"]))
          })
        rescue
          logger.important("Bugnsag deploy notification failed, #{$!.inspect}")
        end

        logger.info "Bugsnag deploy notification complete."
      end
    end
  end
end