Module: DeployInfo::Notifier

Extended by:
Notifier
Included in:
Notifier
Defined in:
lib/deploy-info/notifier.rb

Overview

> Deploy Notification Methods

Instance Method Summary collapse

Instance Method Details

#newrelicObject

> NewRelic <= #



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/deploy-info/notifier.rb', line 26

def newrelic
  return unless Config.query_params['nr_app_id']

  # => Grab the NewRelic Application ID
  nr_app_id = Config.query_params['nr_app_id']

  # => Build the URI & POST Request
  uri = URI.parse("https://api.newrelic.com/v2/applications/#{nr_app_id}/deployments.json")
  request = Net::HTTP::Post.new(uri)

  # => Set Headers
  request.content_type = 'application/json'
  request['X-Api-Key'] = Config.query_params['nr_api_key'] || Config.nr_api_key
  puts Config.nr_api_key

  # => Build the JSON Payload
  request.body = {
    deployment: {
      revision: Git.revision,
      user: Config.query_params['user'],
      description: Config.query_params['comment']
    }
  }.to_json

  # => Send the Deployment Notification
  Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
    http.request(request)
  end
end

#rollbarObject

> Rollbar <= #



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/deploy-info/notifier.rb', line 60

def rollbar
  # => Build the Data Structure
  data = {}
  data[:access_token] = Config.query_params['rb_token']
  data[:environment] = Config.query_params['environment']
  data[:revision] = Git.revision
  data[:local_username] = Config.query_params['user']
  data[:comment] = Config.query_params['comment']

  # => Parse the Destination API URI
  uri = URI.parse('https://api.rollbar.com/api/1/deploy/')

  # => Construct the POST Request
  request = Net::HTTP::Post.new(uri)
  request.set_form_data(data)

  # => Send the Deployment Notification
  Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
    http.request(request)
  end
end