bozo-scripts 0.1.9 → 0.1.10
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/VERSION +1 -1
- data/lib/bozo/hooks/hipchat.rb +102 -0
- data/lib/bozo/hooks/jenkins.rb +1 -0
- data/lib/bozo_scripts.rb +1 -0
- metadata +5 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.10
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module Bozo::Hooks
|
2
|
+
|
3
|
+
# Hooks for notifying Hipchat of the build
|
4
|
+
#
|
5
|
+
# The following env variables are required
|
6
|
+
# - BUILD_URL
|
7
|
+
# - BUILD_NAME
|
8
|
+
#
|
9
|
+
# with_hook :hipchat do |h|
|
10
|
+
# h.token '.....'
|
11
|
+
# h.room_id 'Dev'
|
12
|
+
# h.name 'Bozo'
|
13
|
+
# h.notify :failure
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
class Hipchat
|
17
|
+
require 'net/http'
|
18
|
+
require 'openssl'
|
19
|
+
require 'json'
|
20
|
+
|
21
|
+
COLOR_MAP = { pending: 'gray', success: 'green', failure: 'red' }
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
@name = 'Bozo'
|
25
|
+
@notify = []
|
26
|
+
end
|
27
|
+
|
28
|
+
def pre_build
|
29
|
+
submit_notification(:pending, "Building #{project_name}")
|
30
|
+
end
|
31
|
+
|
32
|
+
def post_build
|
33
|
+
submit_notification(:success, "Built #{project_name}")
|
34
|
+
end
|
35
|
+
|
36
|
+
def failed_build
|
37
|
+
submit_notification(:failure, "Failed to build #{project_name}")
|
38
|
+
end
|
39
|
+
|
40
|
+
def token(token)
|
41
|
+
@token = token
|
42
|
+
end
|
43
|
+
|
44
|
+
def room_id(room)
|
45
|
+
@room = room
|
46
|
+
end
|
47
|
+
|
48
|
+
def name(name)
|
49
|
+
@name = name
|
50
|
+
end
|
51
|
+
|
52
|
+
def notify(state)
|
53
|
+
@notify << state
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def build_url
|
59
|
+
env['BUILD_URL']
|
60
|
+
end
|
61
|
+
|
62
|
+
def build_number
|
63
|
+
env['BUILD_NUMBER']
|
64
|
+
end
|
65
|
+
|
66
|
+
def project_name
|
67
|
+
env['BUILD_NAME']
|
68
|
+
end
|
69
|
+
|
70
|
+
def submit_notification(state, description)
|
71
|
+
return unless build_server?
|
72
|
+
return unless @notify.include?(state)
|
73
|
+
|
74
|
+
log_info "Notifying Hipchat of #{state} - #{description} - #{build_url}"
|
75
|
+
|
76
|
+
message = "#{description} - <a href=\"#{build_url}\">view</a>"
|
77
|
+
|
78
|
+
uri = URI("https://api.hipchat.com/v1/rooms/message?format=json&auth_token=#{@token}")
|
79
|
+
header = {
|
80
|
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
81
|
+
'User-Agent' => 'Bozo Hipchat notifier'
|
82
|
+
}
|
83
|
+
data = URI.encode_www_form({
|
84
|
+
room_id: @room,
|
85
|
+
from: @name,
|
86
|
+
message: message,
|
87
|
+
message_format: 'html',
|
88
|
+
color: COLOR_MAP[state],
|
89
|
+
notify: state == :failure ? '1' : '0'
|
90
|
+
})
|
91
|
+
|
92
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
93
|
+
http.use_ssl = true
|
94
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
95
|
+
http.post(uri.request_uri, data, header)
|
96
|
+
|
97
|
+
log_info "Notified Hipchat of #{state} - #{description} - #{build_url}"
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
data/lib/bozo/hooks/jenkins.rb
CHANGED
data/lib/bozo_scripts.rb
CHANGED
@@ -11,6 +11,7 @@ require 'bozo/hooks/fxcop'
|
|
11
11
|
require 'bozo/hooks/git_commit_hashes'
|
12
12
|
require 'bozo/hooks/git_tag_release'
|
13
13
|
require 'bozo/hooks/git_hub'
|
14
|
+
require 'bozo/hooks/hipchat'
|
14
15
|
require 'bozo/hooks/jenkins'
|
15
16
|
require 'bozo/hooks/teamcity'
|
16
17
|
require 'bozo/hooks/timing'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bozo-scripts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-03-
|
13
|
+
date: 2014-03-26 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/bozo/hooks/git_commit_hashes.rb
|
110
110
|
- lib/bozo/hooks/git_hub.rb
|
111
111
|
- lib/bozo/hooks/git_tag_release.rb
|
112
|
+
- lib/bozo/hooks/hipchat.rb
|
112
113
|
- lib/bozo/hooks/jenkins.rb
|
113
114
|
- lib/bozo/hooks/teamcity.rb
|
114
115
|
- lib/bozo/hooks/timing.rb
|
@@ -139,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
139
140
|
version: '0'
|
140
141
|
segments:
|
141
142
|
- 0
|
142
|
-
hash: -
|
143
|
+
hash: -2293458282868325952
|
143
144
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
145
|
none: false
|
145
146
|
requirements:
|
@@ -148,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
149
|
version: '0'
|
149
150
|
segments:
|
150
151
|
- 0
|
151
|
-
hash: -
|
152
|
+
hash: -2293458282868325952
|
152
153
|
requirements: []
|
153
154
|
rubyforge_project: bozo-scripts
|
154
155
|
rubygems_version: 1.8.24
|