Skip to content

Commit

Permalink
Merge pull request nesquena#9 from demandchain/OP-4013_DFF_newrelic_n…
Browse files Browse the repository at this point in the history
…otice_deployments

Create a notice_deployment task for NewRelic.
  • Loading branch information
donovanbray committed Dec 17, 2013
2 parents 8316589 + dd817c5 commit f160ba3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/cap_recipes/tasks/newrelic_rpm/hooks.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# @author Donovan Bray <[email protected]>

Capistrano::Configuration.instance(true).load do
after "deploy:restart", "newrelic_rpm:notice_deployment"
after "deploy:start", "newrelic_rpm:notice_deployment"
end
21 changes: 20 additions & 1 deletion lib/cap_recipes/tasks/newrelic_rpm/install.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,26 @@

Capistrano::Configuration.instance(true).load do
namespace :newrelic_rpm do
roles[:newrelic_rpm]
#this variable is for compatability with newrelic_nrsysmond, it's not used directly here.
set(:newrelic_rpm_license_key) {utilities.ask("newrelic_rpm_license_key:")}
set(:newrelic_rpm_cli) { "bundle exec newrelic" }
set(:newrelic_rpm_source_benchmark_revision) { previous_revision }
set(:newrelic_rpm_source_changes_command) {
case scm
when :git
%Q{#{source.command} --no-pager log #{newrelic_rpm_source_benchmark_revision}..#{latest_revision} --no-color --pretty=format:"%s - %an, %ad : %H"}
else
%Q{echo "no changes command implemented."}
end
}

desc "Notify New Relic so the deploys will appear in the time series graphs."
task :notice_deployment, :except => { :no_release => true }, :once => true do
# https://docs.newrelic.com/docs/ruby/recording-deployments-with-the-ruby-agent#Manual
# The return of this command is coerced to true because we don't want any failure in
# noticing a deployment to break the deploy.
run "cd #{latest_release} && #{newrelic_rpm_source_changes_command} | #{newrelic_rpm_cli} deployments --environment=#{rails_env} --revision=#{latest_revision} --changes; true"
end

end
end

0 comments on commit f160ba3

Please sign in to comment.