hudson-to-pisswhistle 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,7 @@
1
+ This is a simple script that allows Hudson to post build information to another service.
2
+
3
+ You'll need to install the 'post-build task' plugin, and then set the script to something like this:
4
+
5
+ HOST=localhost:5032 STREAM=freerange OAUTH_KEY=MyKey123 hudson-to-pisswhistle &
6
+
7
+ It's important to remember to run this in the background, because the script needs to wait for the build to finish before build.xml is actually written. That's a pain, but what can you do.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require "hudson_to_pisswhistle"
3
+
4
+ HudsonToPissWhistle.run
@@ -0,0 +1,45 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+ require 'crack'
4
+ require 'json'
5
+
6
+ class HudsonToPissWhistle
7
+ # Hudson's XML keys contain dots, but BSON doesn't like that.
8
+ def self.change_dots_to_hyphens_in_keys(hash)
9
+ hash.inject({}) do |h, (k,v)|
10
+ h[k.to_s.gsub(".", "-")] = v.is_a?(Hash) ? change_dots_to_hyphens_in_keys(v) : v
11
+ h
12
+ end
13
+ end
14
+
15
+ def self.run(net_client=HTTParty)
16
+ %w(STREAM OAUTH_TOKEN WORKSPACE BUILD_ID).each do |setting|
17
+ raise "#{setting} was not set" unless ENV[setting]
18
+ end
19
+
20
+ build_directory = File.expand_path(File.join(ENV["WORKSPACE"], "..", "builds", ENV["BUILD_ID"]))
21
+ build_log = File.join(build_directory, "build.xml")
22
+
23
+ # puts "sleeping while i wait for build.xml to appear"
24
+ x = 0
25
+ until File.exists?(build_log) || x > 10 do
26
+ sleep(1)
27
+ # puts "chekcing for #{build_log}"
28
+ x += 1
29
+ end
30
+ # puts "awake again #{x}"
31
+
32
+ data = Crack::XML.parse(File.read(build_log))
33
+
34
+ data = change_dots_to_hyphens_in_keys(data)
35
+
36
+ data["message"] = File.read(File.join(build_directory, "changelog.xml")).strip
37
+
38
+ # legacy CI message compatibility
39
+ data["result"] = data["build"]["result"]
40
+
41
+ stream_url = "http://#{ENV["HOST"] || "localhost"}/#{ENV["STREAM"]}/messages"
42
+ query = {:type => "hudson", :oauth_token => ENV["OAUTH_TOKEN"], :payload => data.to_json}
43
+ net_client.post(stream_url, :query => query)
44
+ end
45
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hudson-to-pisswhistle
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - James Adam
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-01-06 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: httparty
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 5
30
+ segments:
31
+ - 0
32
+ - 6
33
+ - 1
34
+ version: 0.6.1
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: crack
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 11
46
+ segments:
47
+ - 0
48
+ - 1
49
+ - 8
50
+ version: 0.1.8
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: json
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ hash: 11
62
+ segments:
63
+ - 1
64
+ - 4
65
+ - 6
66
+ version: 1.4.6
67
+ type: :runtime
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: kintama
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ hash: 25
78
+ segments:
79
+ - 0
80
+ - 1
81
+ - 1
82
+ version: 0.1.1
83
+ type: :development
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ name: mocha
87
+ prerelease: false
88
+ requirement: &id005 !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ hash: 25
94
+ segments:
95
+ - 0
96
+ - 9
97
+ version: "0.9"
98
+ type: :development
99
+ version_requirements: *id005
100
+ description:
101
+ email: james@lazyatom.com
102
+ executables:
103
+ - hudson-to-pisswhistle
104
+ extensions: []
105
+
106
+ extra_rdoc_files:
107
+ - README
108
+ files:
109
+ - README
110
+ - bin/hudson-to-pisswhistle
111
+ - lib/hudson_to_pisswhistle.rb
112
+ has_rdoc: true
113
+ homepage: http://gofreerange.com
114
+ licenses: []
115
+
116
+ post_install_message:
117
+ rdoc_options:
118
+ - --main
119
+ - README
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ hash: 3
128
+ segments:
129
+ - 0
130
+ version: "0"
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ hash: 3
137
+ segments:
138
+ - 0
139
+ version: "0"
140
+ requirements: []
141
+
142
+ rubyforge_project:
143
+ rubygems_version: 1.3.7
144
+ signing_key:
145
+ specification_version: 3
146
+ summary: Gathers build data from hudson and posts it to a URL
147
+ test_files: []
148
+