Class: NewRelic::Notificator
- Inherits:
-
Object
- Object
- NewRelic::Notificator
- Defined in:
- lib/newrelic/notificator.rb
Instance Method Summary collapse
-
#initialize(stage, revision, user, newrelic_config_file) ⇒ Notificator
constructor
A new instance of Notificator.
- #notify ⇒ Object
Constructor Details
#initialize(stage, revision, user, newrelic_config_file) ⇒ Notificator
Returns a new instance of Notificator.
7 8 9 10 11 12 |
# File 'lib/newrelic/notificator.rb', line 7 def initialize(stage, revision, user, newrelic_config_file) @stage = stage @revision = revision @user = user @newrelic_config_file = newrelic_config_file end |
Instance Method Details
#notify ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/newrelic/notificator.rb', line 14 def notify new_relic_yml = YAML.load_file(@newrelic_config_file) rescue nil unless new_relic_yml puts "Can't open New Relic config file!" return end config = HashWithIndifferentAccess.new(new_relic_yml)[@stage] = { :revision => @revision, :environment => @stage, :user => @user, :description => config[:description], :license_key => config[:license_key], :appname => config[:app_name] } puts "Uploading deployment to New Relic..." deployment = NewRelic::Cli::Deployments.new deployment.run puts "Uploaded deployment information to New Relic" rescue => e puts "Unable to notify New Relic of the deployment... skipping" puts "Error creating New Relic deployment (#{e})\n#{e.})\n#{e.backtrace.join("\n")}" end |