PerfectlyNormal-integrity-hooks 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2009 Per Christian B. Viken <perchr@northblue.org>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,42 @@
1
+ Integrity
2
+ =========
3
+
4
+ [Integrity](http://integrityapp.com) is your friendly automated Continuous Integration server.
5
+
6
+ Integrity Web Hooks Notifier
7
+ ========================
8
+
9
+ This lets Integrity POST to one or more URLs after a build is completed.
10
+
11
+ The payload
12
+ ===========
13
+
14
+ Each defined URL gets a JSON hash posted to it.
15
+ The contents is as follows:
16
+
17
+ {
18
+ "project" => build.project.name, # "integrity-hooks"
19
+ "short_message" => short_message, # "Built c289a62 successfully"
20
+ "full_message" => full_message, # "Build c289a622ee2771ef7f8f1771d67c3c8971d1fcad was successful
21
+ # Commit Message: make it possible to post to several URLs
22
+ # Commit Date: 2009-07-26T15:39:06+02:00
23
+ # Commit Author: Per Christian B. Viken
24
+ #
25
+ # Link: ...
26
+ #
27
+ # Build Output:
28
+ #
29
+ # ...
30
+ "url" => commit_url # ...
31
+ }
32
+
33
+ Setup Instructions
34
+ ==================
35
+
36
+ Just install this gem with `gem install PerfectlyNormal-integrity-hooks`
37
+ and then in your Rackup (ie, `config.ru`) file:
38
+
39
+ require "rubygems"
40
+ require "integrity/notifier/hooks"
41
+
42
+ Now, just edit the project and the configuration should be there
data/Rakefile ADDED
File without changes
@@ -0,0 +1,19 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "integrity-hooks"
3
+ s.version = "0.0.6"
4
+ s.date = "2009-07-26"
5
+ s.summary = "Web hooks notifier for the Integrity continuous integration server"
6
+ s.homepage = "http://eastblue.org/projects/integrity"
7
+ s.email = "perchr@northblue.org"
8
+ s.authors = ["Per Christian B. Viken"]
9
+ s.has_rdoc = false
10
+ s.files = %w[
11
+ LICENSE
12
+ README.markdown
13
+ Rakefile
14
+ integrity-hooks.gemspec
15
+ lib/integrity/notifier/hooks.rb
16
+ ]
17
+ s.add_dependency "integrity"
18
+ s.add_dependency "json"
19
+ end
@@ -0,0 +1,63 @@
1
+ require "json"
2
+ require "net/http"
3
+ require "net/https"
4
+
5
+ module Integrity
6
+ class Notifier
7
+ class Hooks < Notifier::Base
8
+ attr_reader :uri
9
+
10
+ def self.to_haml
11
+ <<-HAML
12
+ %p.normal
13
+ %label{ :for => "hooks_notifier_uri" } Send to
14
+ To send to multiple URLs, separate the URLs with three stars (***)
15
+ %input.text#hooks_notifier_uri{ |
16
+ :name => "notifiers[Hooks][uri]", |
17
+ :type => "text", |
18
+ :value => config["uri"] } |
19
+ HAML
20
+ end
21
+
22
+ def initialize(build, config={})
23
+ @uri = config.delete("uri")
24
+ super
25
+ end
26
+
27
+ def deliver!
28
+ uri.split("***").each do |target|
29
+ begin
30
+ Timeout.timeout(5) do
31
+ Integrity.log("POSTing to #{target}")
32
+ response = Net::HTTP.post_form(URI.parse(target), {"payload" => payload.to_json})
33
+ case response
34
+ when Net::HTTPSuccess
35
+ Integrity.log("POST to #{target} successful. Response: #{response.body}")
36
+ true
37
+ else
38
+ # TODO: N retries
39
+ Integrity.log("POST to #{target} failed (#{response.code} #{response.msg}). Response: \n#{response.body}")
40
+ false
41
+ end
42
+ end
43
+ rescue Errno::ECONNREFUSED
44
+ Integrity.log("Connection refused for #{target}")
45
+ rescue TimeoutError
46
+ Integrity.log("Timed out POST to #{target}")
47
+ end
48
+ end
49
+ end
50
+
51
+ def payload
52
+ {
53
+ "project" => build.project.name,
54
+ "short_message" => short_message,
55
+ "full_message" => full_message,
56
+ "url" => commit_url
57
+ }
58
+ end
59
+ end
60
+
61
+ register Hooks
62
+ end
63
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: PerfectlyNormal-integrity-hooks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
+ platform: ruby
6
+ authors:
7
+ - Per Christian B. Viken
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-26 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: integrity
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description:
36
+ email: perchr@northblue.org
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - LICENSE
45
+ - README.markdown
46
+ - Rakefile
47
+ - integrity-hooks.gemspec
48
+ - lib/integrity/notifier/hooks.rb
49
+ has_rdoc: false
50
+ homepage: http://eastblue.org/projects/integrity
51
+ post_install_message:
52
+ rdoc_options: []
53
+
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.2.0
72
+ signing_key:
73
+ specification_version: 2
74
+ summary: Web hooks notifier for the Integrity continuous integration server
75
+ test_files: []
76
+