Sha256: b665855a2be0bf525c374be04eb2b3adaf9c8f1940c5172c7d2ad1d5fae1cac9

Contents?: true

Size: 1.62 KB

Versions: 238

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

module Appsignal
  # @todo Move to sub-namespace
  # @api private
  class Capistrano
    def self.tasks(config)
      config.load do # rubocop:disable Metrics/BlockLength
        after "deploy", "appsignal:deploy"
        after "deploy:migrations", "appsignal:deploy"

        namespace :appsignal do
          task :deploy do
            env = fetch(:appsignal_env, fetch(:stage, fetch(:rails_env, fetch(:rack_env, "production"))))
            user = fetch(:appsignal_user, ENV["USER"] || ENV["USERNAME"])
            revision = fetch(:appsignal_revision, fetch(:current_revision))

            appsignal_config = Appsignal::Config.new(
              ENV["PWD"],
              env,
              {},
              Logger.new(StringIO.new)
            ).tap do |c|
              fetch(:appsignal_config, {}).each do |key, value|
                c[key] = value
              end
              c.validate
            end

            if appsignal_config && appsignal_config.active?
              marker_data = {
                :revision => revision,
                :user => user
              }

              marker = Marker.new(marker_data, appsignal_config)
              if config.dry_run
                puts "Dry run: AppSignal deploy marker not actually sent."
              else
                marker.transmit
              end
            else
              puts "Not notifying of deploy, config is not active for environment: #{env}"
            end
          end
        end
      end
    end
  end
end

if ::Capistrano::Configuration.instance
  Appsignal::Capistrano.tasks(::Capistrano::Configuration.instance)
end

Version data entries

238 entries across 238 versions & 1 rubygems

Version Path
appsignal-3.1.6-java lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.1.6 lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.1.5-java lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.1.5 lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.1.4-java lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.1.4 lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.1.3-java lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.1.3 lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.1.2-java lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.1.2 lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.1.1-java lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.1.1 lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.1.0-java lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.1.0 lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.0.27-java lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.0.27 lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.0.26-java lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.0.26 lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.0.25-java lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb
appsignal-3.0.25 lib/appsignal/integrations/capistrano/capistrano_2_tasks.rb