Created
December 27, 2013 00:07
Honeybadger.io deploy task for Capistrano 3
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
namespace :deploy do | |
desc "Notifies Honeybadger locally using curl" | |
task :notify_honeybadger do | |
on roles(:app) do | |
require 'json' | |
require 'honeybadger' | |
begin | |
require './config/initializers/honeybadger' | |
rescue LoadError | |
error 'Honeybadger initializer not found' | |
else | |
honeybadger_api_key = Honeybadger.configuration.api_key | |
honeybadger_env = fetch(:rails_env, "production") | |
current_revision = fetch(:current_revision) | |
notify_command = "curl -sd 'deploy[repository]=#{repo_url}&deploy[revision]=#{current_revision}&deploy[local_username]=#{local_user}&deploy[environment]=#{honeybadger_env}&api_key=#{honeybadger_api_key}' https://api.honeybadger.io/v1/deploys" | |
info "Notifying Honeybadger of Deploy (`#{notify_command}`)" | |
result = JSON.parse `#{notify_command}` rescue nil | |
result ||= { 'error' => 'Invalid response' } | |
if result.include?('error') | |
error "Honeybadger Notification Failed: #{result['error']}" | |
else | |
info "Honeybadger Notification Complete." | |
end | |
end | |
end | |
end | |
after :finishing, :notify_honeybadger | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment