Sha256: 23dd2a462849db195c2e6c81d24acb893bd4a7516180d6b2df03d86d0647f700

Contents?: true

Size: 1.45 KB

Versions: 2

Compression:

Stored size: 1.45 KB

Contents

namespace :load do

  task :defaults do

    set :bugsnag_default_hooks, ->{ true }

  end

end

namespace :deploy do

  before :starting, :bugsnag_hooks do
    invoke 'bugsnag:add_default_hooks' if fetch(:bugsnag_default_hooks)
  end

end

namespace :bugsnag do

  task :add_default_hooks do
    after 'deploy:published', 'bugsnag:deploy'
  end

  desc 'Notify Bugsnag that new production code has been deployed'
  task :deploy do
    on primary(:app) do
      ALLOWED_ENV_SETTINGS = %w{BUGSNAG_RELEASE_STAGE BUGSNAG_REPOSITORY BUGSNAG_REVISION BUGSNAG_BRANCH BUGSNAG_API_KEY BUGSNAG_APP_VERSION}

      rails_env    = fetch(:rails_env) || fetch(:stage)
      bugsnag_env  = fetch(:bugsnag_env, rails_env)

      # Build the new environment to pass through to rake
      new_env = {
        "BUGSNAG_RELEASE_STAGE" => bugsnag_env,
        "BUGSNAG_REVISION"      => fetch(:current_revision, nil),
        "BUGSNAG_REPOSITORY"    => fetch(:repo_url, nil),
        "BUGSNAG_BRANCH"        => fetch(:branch, nil),
        "BUGSNAG_API_KEY"       => fetch(:bugsnag_api_key, nil)
      }.reject { |_, v| v.nil? }

      # Pass through any existing env variables
      ALLOWED_ENV_SETTINGS.each { |opt| new_env[opt] = ENV[opt] if ENV[opt] }

      within release_path do
        with rails_env: rails_env do
          execute rake, "bugsnag:deploy #{new_env.map{|k,v| "#{k}=#{v}"}.join(" ")}"
        end
      end

      info 'Bugsnag deploy notification complete.'
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bugsnag-1.8.6 lib/bugsnag/tasks/bugsnag.cap
bugsnag-1.8.5 lib/bugsnag/tasks/bugsnag.cap