Skip to content

Commit

Permalink
Merge pull request #79 from morgoth/fix-passing-api-key-as-param-to-r…
Browse files Browse the repository at this point in the history
…ake-task

fixed passing api_key param to Airbrake deploy task
  • Loading branch information
shime committed May 2, 2012
2 parents 5ded1ff + 8f7dab9 commit a416173
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/airbrake_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ module AirbrakeTasks
#
# @param [Hash] opts Data about the deploy that is set to Airbrake
#
# @option opts [String] :api_key Api key of you Airbrake application
# @option opts [String] :rails_env Environment of the deploy (production, staging)
# @option opts [String] :scm_revision The given revision/sha that is being deployed
# @option opts [String] :scm_repository Address of your repository to help with code lookups
# @option opts [String] :local_username Who is deploying
def self.deploy(opts = {})
if Airbrake.configuration.api_key.blank?
api_key = opts.delete(:api_key) || Airbrake.configuration.api_key
if api_key.blank?
puts "I don't seem to be configured with an API key. Please check your configuration."
return false
end
Expand All @@ -25,7 +27,7 @@ def self.deploy(opts = {})
end

dry_run = opts.delete(:dry_run)
params = {'api_key' => opts.delete(:api_key) || Airbrake.configuration.api_key}
params = {'api_key' => api_key}
opts.each {|k,v| params["deploy[#{k}]"] = v }

host = Airbrake.configuration.host || 'airbrake.io'
Expand All @@ -37,18 +39,18 @@ def self.deploy(opts = {})
Airbrake.configuration.proxy_pass)
http = proxy.new(host, port)



# Handle Security
if Airbrake.configuration.secure?
http.use_ssl = true
http.ca_file = Airbrake.configuration.ca_bundle_path
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
end

post = Net::HTTP::Post.new("/deploys.txt")
post.set_form_data(params)

if dry_run
puts http.inspect, params.inspect
return true
Expand Down

0 comments on commit a416173

Please sign in to comment.