Sha256: eddb477b7459c2dda20869802a43ee57310eb3f8e3e2c4daf1bd6579915dbdbf

Contents?: true

Size: 1.16 KB

Versions: 8

Compression:

Stored size: 1.16 KB

Contents

require "json"

module Bugsnag
  class Deploy
    def self.notify(opts = {})

      configuration = Bugsnag.configuration.dup

      # update configuration based on parameters passed in
      [:api_key, :app_version, :release_stage, :endpoint, :use_ssl,
       :proxy_host, :proxy_port, :proxy_user, :proxy_password].each do |param|
        unless opts[param].nil?
          configuration.send :"#{param}=", opts[param]
        end
      end

      endpoint = (configuration.use_ssl ? "https://" : "http://") + configuration.endpoint + "/deploy"

      parameters = {
        "apiKey" => configuration.api_key,
        "releaseStage" => configuration.release_stage,
        "appVersion" => configuration.app_version,
        "revision" => opts[:revision],
        "repository" => opts[:repository],
        "branch" => opts[:branch],
        "provider" => opts[:provider]
      }.reject {|k,v| v == nil}

      raise RuntimeError.new("No API key found when notifying of deploy") if !parameters["apiKey"] || parameters["apiKey"].empty?

      payload_string = ::JSON.dump(parameters)
      Bugsnag::Delivery::Synchronous.deliver(endpoint, payload_string, configuration)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bugsnag-5.5.0 lib/bugsnag/deploy.rb
bugsnag-5.4.1 lib/bugsnag/deploy.rb
bugsnag-5.4.0 lib/bugsnag/deploy.rb
bugsnag-5.3.3 lib/bugsnag/deploy.rb
bugsnag-5.3.2 lib/bugsnag/deploy.rb
bugsnag-5.3.1 lib/bugsnag/deploy.rb
bugsnag-5.3.0 lib/bugsnag/deploy.rb
bugsnag-5.2.0 lib/bugsnag/deploy.rb