Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 51 lines (41 sloc) 1.682 kb
e4dbd3d Added rake task. Testing inside a real app
Tammer Saleh authored
1 require 'net/http'
2 require 'uri'
3 require 'active_support'
4
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
5 # Capistrano tasks for notifying Airbrake of deploys
6 module AirbrakeTasks
5e7a896 @qrush Fleshing out more docs
qrush authored
7
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
8 # Alerts Airbrake of a deploy.
5e7a896 @qrush Fleshing out more docs
qrush authored
9 #
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
10 # @param [Hash] opts Data about the deploy that is set to Airbrake
5e7a896 @qrush Fleshing out more docs
qrush authored
11 #
12 # @option opts [String] :rails_env Environment of the deploy (production, staging)
13 # @option opts [String] :scm_revision The given revision/sha that is being deployed
14 # @option opts [String] :scm_repository Address of your repository to help with code lookups
15 # @option opts [String] :local_username Who is deploying
e2716d4 refactored deploy class method to add flexibility in args list #321
Tammer Saleh authored
16 def self.deploy(opts = {})
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
17 if Airbrake.configuration.api_key.blank?
e4dbd3d Added rake task. Testing inside a real app
Tammer Saleh authored
18 puts "I don't seem to be configured with an API key. Please check your configuration."
19 return false
20 end
21
e2716d4 refactored deploy class method to add flexibility in args list #321
Tammer Saleh authored
22 if opts[:rails_env].blank?
9cdd038 Bugfixes to deploy task
Tammer Saleh authored
23 puts "I don't know to which Rails environment you are deploying (use the TO=production option)."
e4dbd3d Added rake task. Testing inside a real app
Tammer Saleh authored
24 return false
25 end
26
19d05bb @jyurek Tweaks to allowing a dry_run option.
jyurek authored
27 dry_run = opts.delete(:dry_run)
4d7181f @natacado Allow passing an API_KEY as part of the hoptoad:deploy rake task
natacado authored
28 params = {'api_key' => opts.delete(:api_key) ||
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
29 Airbrake.configuration.api_key}
e292e3b capistrano task, rake task, and ruby code are now all cooperating to …
Tammer Saleh authored
30 opts.each {|k,v| params["deploy[#{k}]"] = v }
31
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
32 url = URI.parse("http://#{Airbrake.configuration.host || 'airbrakeapp.com'}/deploys.txt")
f339b7e @jasonm Support the proxy configuration options when notifying Hoptoad of a d…
jasonm authored
33
ceb0feb @jyurek WIP: Hoptoad -> Airbrake
jyurek authored
34 proxy = Net::HTTP.Proxy(Airbrake.configuration.proxy_host,
35 Airbrake.configuration.proxy_port,
36 Airbrake.configuration.proxy_user,
37 Airbrake.configuration.proxy_pass)
19d05bb @jyurek Tweaks to allowing a dry_run option.
jyurek authored
38
39 if dry_run
496f12b Added support for --dry-run option to deploy task.(cherry picked from…
Alessandro Morandi authored
40 puts url, params.inspect
41 return true
42 else
43 response = proxy.post_form(url, params)
44
45 puts response.body
46 return Net::HTTPSuccess === response
47 end
e4dbd3d Added rake task. Testing inside a real app
Tammer Saleh authored
48 end
49 end
50
Something went wrong with that request. Please try again.