Sha256: 777859f732f9ff11eb42fada5b83751001458a3f4bb627828029d5e01e7b38f9

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

require "bugsnag"

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]
      }.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

1 entries across 1 versions & 1 rubygems

Version Path
bugsnag-2.8.9 lib/bugsnag/deploy.rb