cruisecontrolrb_to_hipchat 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/bin/cruisecontrolrb_to_hipchat +20 -0
- data/cruisecontrolrb_to_hipchat.gemspec +29 -0
- data/lib/cruisecontrolrb_to_hipchat.rb +59 -0
- data/lib/cruisecontrolrb_to_hipchat/cruisecontrolrb.rb +35 -0
- data/lib/cruisecontrolrb_to_hipchat/hipchat.rb +18 -0
- data/lib/cruisecontrolrb_to_hipchat/version.rb +3 -0
- data/test.rb +11 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a3a4f5d9a20f3fbddddcb6384b120cfe03a92f66
|
4
|
+
data.tar.gz: a72a8694de06e3f4b81a273d8346e00af53e19a4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 922963784bf5fd209f9bdef8e97c1deae19067d0873f28df1418229262494a83f8f498375964a0868ec285b3be1e5fd6e47252f0e614d0d3bdbdbc7fc9880aff
|
7
|
+
data.tar.gz: 6ef87dfc667c106a55ff2346bb320ae0a8716d81952cf1470c4d26375d73eb8ee9dff31cea812a1694f30bb357eaaaa6f7b613801971f9509a02ab95db68edd5
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Emmanuel Pinault
|
2
|
+
|
3
|
+
MIT License
|
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
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
This is a little Sinatra app notifies Hipchat of any changes in the build status on your CruiseControl.rb install.
|
2
|
+
|
3
|
+
Heroku-ready! Just follow these steps:
|
4
|
+
|
5
|
+
1. Grab a copy of the source
|
6
|
+
|
7
|
+
git clone git@github.com:andrewpbrett/cruisecontrolrb_to_hipchat.git
|
8
|
+
|
9
|
+
2. Create a Heroku app
|
10
|
+
|
11
|
+
heroku create myapp
|
12
|
+
|
13
|
+
3. Required configuration
|
14
|
+
|
15
|
+
heroku config:add HIPCHAT_AUTH_TOKEN=your_auth_token
|
16
|
+
heroku config:add HIPCHAT_ROOM_ID=your_room_id
|
17
|
+
heroku config:add CC_URL=your_cruise_control_url
|
18
|
+
|
19
|
+
4. Optional configuration:
|
20
|
+
|
21
|
+
Basic auth for your CruiseControlrb install (recommended):
|
22
|
+
|
23
|
+
heroku config:add CC_USERNAME=your_username
|
24
|
+
heroku config:add CC_PASSWORD=your_password
|
25
|
+
|
26
|
+
heroku config:add POLLING_INTERVAL # polling interval in minutes. defaults to 1 minute.
|
27
|
+
heroku config:add HIPCHAT_FROM=cruise-control # who the messages are "from" in hipchat. defaults to 'cruise-control'
|
28
|
+
|
29
|
+
5. Deploy to Heroku
|
30
|
+
|
31
|
+
git push heroku master
|
32
|
+
|
33
|
+
6. Set up something to ping your app regularly in order to [prevent it from idling](http://stackoverflow.com/questions/5480337/easy-way-to-prevent-heroku-idling). The New Relic add-on seems to do the trick, but so does a cron job, pingdom, etc., etc., etc. ...
|
34
|
+
|
35
|
+
7. Have a beer while you wait for your first notification in Hipchat.
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'cruisecontrolrb_to_hipchat'
|
4
|
+
|
5
|
+
Dante.run('myapp') do |opts|
|
6
|
+
# opts: host, pid_path, port, daemonize, user, group
|
7
|
+
|
8
|
+
raise 'Missing required Cruisecontrol host: export CC_HOST=<your_cc_host>' unless host = ENV["CC_HOST"]
|
9
|
+
raise 'Missing required HipChat api token, export HIPCHAT_AUTH_TOKEN=<token>' unless token = ENV["HIPCHAT_AUTH_TOKEN"]
|
10
|
+
raise 'Missing required HipChat Room to send message to, export HIPCHAT_ROOM_ID=<room_id>' unless room = ENV["HIPCHAT_ROOM_ID"]
|
11
|
+
|
12
|
+
options = {cc_host: host,
|
13
|
+
cc_username: ENV["CC_USERNAME"] || "",
|
14
|
+
cc_password: ENV["CC_PASSWORD"] || "",
|
15
|
+
hipchat_api_token: token,
|
16
|
+
hipchat_room_id: room ,
|
17
|
+
polling_interval: ENV["POLLING_INTERVAL"] || 5}
|
18
|
+
|
19
|
+
CruisecontrolrbToHipchat::Runner.run(options)
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cruisecontrolrb_to_hipchat/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cruisecontrolrb_to_hipchat"
|
8
|
+
spec.version = CruisecontrolrbToHipchat::VERSION
|
9
|
+
spec.authors = ["epinault"]
|
10
|
+
spec.email = ["emmanuel.pinault@zumobi.com"]
|
11
|
+
spec.summary = %q{A simple daemon to report last build status from cruisecontrol}
|
12
|
+
spec.description = %q{Inspired from https://github.com/andrewpbrett/cruisecontrolrb_to_hipchat but with support of more recent api and multiple projects}
|
13
|
+
spec.homepage = "http://github.com/zumobi/cruisecontrolrb_to_hipchat"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "dante", "~> 0.2.0"
|
22
|
+
spec.add_dependency "hipchat", "~> 1.2.0"
|
23
|
+
spec.add_dependency "nokogiri", "~> 1.6.2"
|
24
|
+
spec.add_dependency "httparty", "~> 0.13.1"
|
25
|
+
spec.add_dependency "rufus-scheduler"
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "cruisecontrolrb_to_hipchat/version"
|
2
|
+
require "cruisecontrolrb_to_hipchat/cruisecontrolrb"
|
3
|
+
require "cruisecontrolrb_to_hipchat/hipchat"
|
4
|
+
require 'httparty'
|
5
|
+
require 'nokogiri'
|
6
|
+
require 'hipchat'
|
7
|
+
require 'dante'
|
8
|
+
require 'rufus-scheduler'
|
9
|
+
|
10
|
+
module CruisecontrolrbToHipchat
|
11
|
+
|
12
|
+
class Runner
|
13
|
+
attr_accessor :previous_statuses
|
14
|
+
attr_accessor :current_activities
|
15
|
+
attr_reader :config
|
16
|
+
|
17
|
+
def self.run(config)
|
18
|
+
new(config).execute
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(config)
|
22
|
+
@config = config
|
23
|
+
@previous_statuses = {}
|
24
|
+
@current_activities = {}
|
25
|
+
end
|
26
|
+
|
27
|
+
def execute
|
28
|
+
scheduler = Rufus::Scheduler.new(:blocking => true, :overlap => false)
|
29
|
+
|
30
|
+
scheduler.every("#{config[:polling_interval]}s") do
|
31
|
+
|
32
|
+
statuses = Cruisecontrolrb.new(config[:cc_host], config[:cc_username], config[:cc_password]).fetch_statuses
|
33
|
+
|
34
|
+
unless statuses.empty?
|
35
|
+
|
36
|
+
statuses.each do |status_hash|
|
37
|
+
name = status_hash[:name]
|
38
|
+
url = File.join(status_hash[:webUrl].gsub("projects", "builds"), status_hash[:lastBuildLabel])
|
39
|
+
|
40
|
+
if status_hash[:activity] == "Building" and current_activities[name] != "Building"
|
41
|
+
msg = "CruiseControl has started to build project #{name}. <a href=\"#{url}\">See details</a>"
|
42
|
+
Hipchat.new(config[:hipchat_api_token], config[:hipchat_room_id]).send_message msg
|
43
|
+
current_activities[name] = "Building"
|
44
|
+
elsif (current_activities[name] == "Building" and status_hash[:activity] != "Building")
|
45
|
+
current_activities[name] = status_hash[:activity]
|
46
|
+
|
47
|
+
color = (status_hash[:lastBuildStatus] == "Success") ? "green" : "red"
|
48
|
+
message = (status_hash[:lastBuildStatus] == "Success") ? "<a href=\"#{url}\">Success</a>! #{name} is looking good. You are a stud! :D" : "You are a failure! #{name} is broken. <a href=\"#{url}\">See details</a> and fix it now! >:-("
|
49
|
+
Hipchat.new(config[:hipchat_api_token], config[:hipchat_room_id]).send_message message, color
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
scheduler.join
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
module CruisecontrolrbToHipchat
|
5
|
+
|
6
|
+
class Cruisecontrolrb
|
7
|
+
|
8
|
+
include HTTParty
|
9
|
+
|
10
|
+
def initialize(base_url, username = nil, password = nil)
|
11
|
+
@auth = { :username => username, :password => password }
|
12
|
+
@base_url = base_url
|
13
|
+
end
|
14
|
+
|
15
|
+
def fetch_statuses
|
16
|
+
options = { :basic_auth => @auth }
|
17
|
+
|
18
|
+
noko = Nokogiri::XML(self.class.get("http://#{@base_url}/XmlStatusReport.aspx", options).parsed_response)
|
19
|
+
projects = noko.search("Project")
|
20
|
+
return [] unless projects.first
|
21
|
+
|
22
|
+
projects.map do |project|
|
23
|
+
|
24
|
+
status_hash = { lastBuildStatus: project["lastBuildStatus"],
|
25
|
+
webUrl: project["webUrl"],
|
26
|
+
lastBuildLabel: project["lastBuildLabel"],
|
27
|
+
activity: project["activity"],
|
28
|
+
name: project['name'] }
|
29
|
+
status_hash
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
module CruisecontrolrbToHipchat
|
3
|
+
class Hipchat
|
4
|
+
attr_reader :client, :options
|
5
|
+
def initialize(api_token, room, options = {})
|
6
|
+
@options = options
|
7
|
+
@options[:user] ||= "cruise-control"
|
8
|
+
@options[:notify] ||= true
|
9
|
+
@room = room
|
10
|
+
@client = HipChat::Client.new(api_token)
|
11
|
+
end
|
12
|
+
|
13
|
+
def send_message(mesg, color = nil)
|
14
|
+
client[@room].send(options[:user], mesg, {:notify => options[:notify], :color => color})
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/test.rb
ADDED
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cruisecontrolrb_to_hipchat
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- epinault
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dante
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hipchat
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.2.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.2.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.6.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.13.1
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.13.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rufus-scheduler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.6'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.6'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Inspired from https://github.com/andrewpbrett/cruisecontrolrb_to_hipchat
|
112
|
+
but with support of more recent api and multiple projects
|
113
|
+
email:
|
114
|
+
- emmanuel.pinault@zumobi.com
|
115
|
+
executables:
|
116
|
+
- cruisecontrolrb_to_hipchat
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- Gemfile
|
122
|
+
- Gemfile.lock
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/cruisecontrolrb_to_hipchat
|
127
|
+
- cruisecontrolrb_to_hipchat.gemspec
|
128
|
+
- lib/cruisecontrolrb_to_hipchat.rb
|
129
|
+
- lib/cruisecontrolrb_to_hipchat/cruisecontrolrb.rb
|
130
|
+
- lib/cruisecontrolrb_to_hipchat/hipchat.rb
|
131
|
+
- lib/cruisecontrolrb_to_hipchat/version.rb
|
132
|
+
- test.rb
|
133
|
+
homepage: http://github.com/zumobi/cruisecontrolrb_to_hipchat
|
134
|
+
licenses:
|
135
|
+
- MIT
|
136
|
+
metadata: {}
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
requirements: []
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 2.2.2
|
154
|
+
signing_key:
|
155
|
+
specification_version: 4
|
156
|
+
summary: A simple daemon to report last build status from cruisecontrol
|
157
|
+
test_files: []
|