integrity-hooks 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/LICENSE +22 -0
- data/README.markdown +45 -0
- data/Rakefile +0 -0
- data/TODO +1 -0
- data/integrity-hooks.gemspec +21 -0
- data/lib/integrity/notifier/hooks.rb +63 -0
- metadata +91 -0
data/ChangeLog
ADDED
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,45 @@
|
|
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
|
+
Add this gem to your `Gemfile`:
|
37
|
+
|
38
|
+
gem "integrity-hooks", "0.0.8"
|
39
|
+
|
40
|
+
Then some trickery with the bundler (`bundle unlock && bundle install && bundle pack`).
|
41
|
+
Finally, in your `init.rb`:
|
42
|
+
|
43
|
+
require "integrity/notifier/hooks"
|
44
|
+
|
45
|
+
Now, just edit the project and the configuration should be there
|
data/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "integrity-hooks"
|
3
|
+
s.version = "0.0.8"
|
4
|
+
s.date = "2010-02-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
|
+
ChangeLog
|
12
|
+
TODO
|
13
|
+
LICENSE
|
14
|
+
README.markdown
|
15
|
+
Rakefile
|
16
|
+
integrity-hooks.gemspec
|
17
|
+
lib/integrity/notifier/hooks.rb
|
18
|
+
]
|
19
|
+
s.add_dependency "integrity"
|
20
|
+
s.add_dependency "json"
|
21
|
+
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,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: integrity-hooks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 8
|
9
|
+
version: 0.0.8
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Per Christian B. Viken
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-02-26 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: integrity
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :runtime
|
31
|
+
version_requirements: *id001
|
32
|
+
- !ruby/object:Gem::Dependency
|
33
|
+
name: json
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
version: "0"
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id002
|
44
|
+
description:
|
45
|
+
email: perchr@northblue.org
|
46
|
+
executables: []
|
47
|
+
|
48
|
+
extensions: []
|
49
|
+
|
50
|
+
extra_rdoc_files: []
|
51
|
+
|
52
|
+
files:
|
53
|
+
- ChangeLog
|
54
|
+
- TODO
|
55
|
+
- LICENSE
|
56
|
+
- README.markdown
|
57
|
+
- Rakefile
|
58
|
+
- integrity-hooks.gemspec
|
59
|
+
- lib/integrity/notifier/hooks.rb
|
60
|
+
has_rdoc: true
|
61
|
+
homepage: http://eastblue.org/projects/integrity
|
62
|
+
licenses: []
|
63
|
+
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
version: "0"
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.3.6
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Web hooks notifier for the Integrity continuous integration server
|
90
|
+
test_files: []
|
91
|
+
|