Created
August 13, 2012 06:14
-
-
Save hrp/3337372 to your computer and use it in GitHub Desktop.
Faster Airbrake Deploy Notifier for Capistrano
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'uri' | |
namespace :airbrake do | |
task :notify, except: {no_release: true} do | |
api_key = API_KEY | |
rails_env = fetch(:rails_env, "production") | |
airbrake_env = fetch(:airbrake_env, fetch(:rails_env, "production")) | |
local_user = ENV['USER'] || ENV['USERNAME'] | |
uri = URI('http://api.airbrake.io/deploys.txt') | |
params = { | |
api_key: api_key, | |
'deploy[rails_env]' => rails_env, | |
'deploy[local_username]' => local_user, | |
'deploy[scm_repository]' => repository, | |
'deploy[scm_revision]' => current_revision | |
} | |
logger.info "Notifying Airbrake of Deploy." | |
if dry_run | |
logger.info "DRY RUN: Notification not actually run." | |
else | |
response = Net::HTTP.post_form(uri, params) | |
logger.info response.body | |
end | |
logger.info "Airbrake Notification Complete." | |
end | |
end | |
after "deploy", "airbrake:notify" | |
after "deploy:migrations", "airbrake:notify" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment