hudson-remote-api 0.1.0 → 0.2.0
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 +19 -0
- data/README +5 -2
- data/VERSION +1 -1
- data/hudson-remote-api.gemspec +23 -5
- data/lib/hudson-remote-api.rb +29 -21
- data/lib/hudson-remote-api/build.rb +7 -7
- data/lib/hudson-remote-api/build_queue.rb +8 -3
- data/lib/hudson-remote-api/config.rb +46 -0
- data/lib/hudson-remote-api/job.rb +35 -34
- data/lib/hudson-remote-api/multicast.rb +22 -0
- data/test/test_hudson_build.rb +12 -0
- data/test/test_hudson_build_queue.rb +11 -0
- data/test/test_hudson_config.rb +30 -0
- data/test/test_hudson_job.rb +19 -0
- data/test/test_hudson_multicast.rb +11 -0
- data/test/test_hudson_remote_api.rb +2 -0
- metadata +21 -6
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2010 Dru Ibarra
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README
CHANGED
@@ -4,8 +4,11 @@ Usage:
|
|
4
4
|
|
5
5
|
require 'hudson-remote-api'
|
6
6
|
|
7
|
-
# Configuration
|
8
|
-
Hudson
|
7
|
+
# Auto Configuration sets Hudson[:url]
|
8
|
+
Hudson.auto_config
|
9
|
+
|
10
|
+
# Manual Configuration
|
11
|
+
Hudson[:url] = 'http://localhost:8080'
|
9
12
|
Hudson[:user] = 'hudson'
|
10
13
|
Hudson[:password] = 'password'
|
11
14
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/hudson-remote-api.gemspec
CHANGED
@@ -1,22 +1,24 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{hudson-remote-api}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dru Ibarra"]
|
12
|
-
s.date = %q{2010-09-
|
12
|
+
s.date = %q{2010-09-03}
|
13
13
|
s.description = %q{Connect to Hudson's remote web API}
|
14
14
|
s.email = %q{Druwerd@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
|
-
"
|
16
|
+
"LICENSE",
|
17
|
+
"README"
|
17
18
|
]
|
18
19
|
s.files = [
|
19
20
|
".gitignore",
|
21
|
+
"LICENSE",
|
20
22
|
"README",
|
21
23
|
"Rakefile",
|
22
24
|
"VERSION",
|
@@ -24,8 +26,16 @@ Gem::Specification.new do |s|
|
|
24
26
|
"lib/hudson-remote-api.rb",
|
25
27
|
"lib/hudson-remote-api/build.rb",
|
26
28
|
"lib/hudson-remote-api/build_queue.rb",
|
29
|
+
"lib/hudson-remote-api/config.rb",
|
27
30
|
"lib/hudson-remote-api/errors.rb",
|
28
|
-
"lib/hudson-remote-api/job.rb"
|
31
|
+
"lib/hudson-remote-api/job.rb",
|
32
|
+
"lib/hudson-remote-api/multicast.rb",
|
33
|
+
"test/test_hudson_build.rb",
|
34
|
+
"test/test_hudson_build_queue.rb",
|
35
|
+
"test/test_hudson_config.rb",
|
36
|
+
"test/test_hudson_job.rb",
|
37
|
+
"test/test_hudson_multicast.rb",
|
38
|
+
"test/test_hudson_remote_api.rb"
|
29
39
|
]
|
30
40
|
s.homepage = %q{http://github.com/Druwerd/hudson-remote-api}
|
31
41
|
s.rdoc_options = ["--charset=UTF-8"]
|
@@ -33,6 +43,14 @@ Gem::Specification.new do |s|
|
|
33
43
|
s.rubyforge_project = %q{hudson-remote-api}
|
34
44
|
s.rubygems_version = %q{1.3.7}
|
35
45
|
s.summary = %q{Connect to Hudson's remote web API}
|
46
|
+
s.test_files = [
|
47
|
+
"test/test_hudson_build.rb",
|
48
|
+
"test/test_hudson_build_queue.rb",
|
49
|
+
"test/test_hudson_config.rb",
|
50
|
+
"test/test_hudson_job.rb",
|
51
|
+
"test/test_hudson_multicast.rb",
|
52
|
+
"test/test_hudson_remote_api.rb"
|
53
|
+
]
|
36
54
|
|
37
55
|
if s.respond_to? :specification_version then
|
38
56
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
data/lib/hudson-remote-api.rb
CHANGED
@@ -3,35 +3,35 @@
|
|
3
3
|
# Author:: Dru Ibarra
|
4
4
|
|
5
5
|
require 'net/http'
|
6
|
+
require 'uri'
|
6
7
|
require 'rexml/document'
|
7
8
|
require 'cgi'
|
8
9
|
require 'yaml'
|
9
10
|
require 'zlib'
|
11
|
+
require File.dirname(__FILE__) + '/hudson-remote-api/config.rb'
|
10
12
|
|
11
13
|
module Hudson
|
12
|
-
@@settings = {:host => 'localhost', :port => 80, :user => nil, :password => nil}
|
13
|
-
|
14
|
-
def self.[](param)
|
15
|
-
return @@settings[param]
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.[]=(param,value)
|
19
|
-
@@settings[param]=value
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.settings=(settings)
|
23
|
-
@@settings = settings
|
24
|
-
end
|
25
|
-
|
26
|
-
HUDSON_URL_ROOT = ""
|
27
14
|
# Base class for all Hudson objects
|
28
15
|
class HudsonObject
|
29
|
-
|
30
|
-
|
16
|
+
|
17
|
+
|
18
|
+
def self.load_xml_api
|
19
|
+
@@hudson_xml_api_path = File.join(Hudson[:url], "api/xml")
|
20
|
+
@@xml_api_create_item_path = File.join(Hudson[:url], "createItem")
|
21
|
+
end
|
22
|
+
|
23
|
+
load_xml_api
|
24
|
+
|
25
|
+
def self.get_xml(url)
|
26
|
+
puts url
|
27
|
+
uri = URI.parse(url)
|
28
|
+
host = uri.host
|
29
|
+
port = uri.port
|
30
|
+
path = uri.path
|
31
31
|
request = Net::HTTP::Get.new(path)
|
32
32
|
request.basic_auth(Hudson[:user], Hudson[:password]) if Hudson[:user] and Hudson[:password]
|
33
33
|
request['Content-Type'] = "text/xml"
|
34
|
-
response = Net::HTTP.start(
|
34
|
+
response = Net::HTTP.start(host, port){|http| http.request(request)}
|
35
35
|
|
36
36
|
if response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
|
37
37
|
encoding = response.get_fields("Content-Encoding")
|
@@ -50,21 +50,29 @@ module Hudson
|
|
50
50
|
self.class.get_xml(path)
|
51
51
|
end
|
52
52
|
|
53
|
-
def send_post_request(
|
53
|
+
def send_post_request(url, data={})
|
54
|
+
uri = URI.parse(url)
|
55
|
+
host = uri.host
|
56
|
+
port = uri.port
|
57
|
+
path = uri.path
|
54
58
|
request = Net::HTTP::Post.new(path)
|
55
59
|
request.basic_auth(Hudson[:user], Hudson[:password]) if Hudson[:user] and Hudson[:password]
|
56
60
|
request.set_form_data(data)
|
57
61
|
#puts request.to_yaml
|
58
|
-
Net::HTTP.new(
|
62
|
+
Net::HTTP.new(host, port).start{|http| http.request(request)}
|
59
63
|
end
|
60
64
|
|
61
65
|
def send_xml_post_request(path, xml)
|
66
|
+
uri = URI.parse(url)
|
67
|
+
host = uri.host
|
68
|
+
port = uri.port
|
69
|
+
path = uri.path
|
62
70
|
request = Net::HTTP::Post.new(path)
|
63
71
|
request.basic_auth(Hudson[:user], Hudson[:password]) if Hudson[:user] and Hudson[:password]
|
64
72
|
request.body = xml
|
65
73
|
#puts request.body
|
66
74
|
#puts request.to_yaml
|
67
|
-
Net::HTTP.new(
|
75
|
+
Net::HTTP.new(host, port).start{|http| http.request(request)}
|
68
76
|
end
|
69
77
|
end
|
70
78
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'hudson-remote-api'
|
2
1
|
module Hudson
|
3
2
|
class Build < HudsonObject
|
4
3
|
attr_reader :number, :job, :revisions, :result
|
@@ -12,18 +11,19 @@ module Hudson
|
|
12
11
|
@number = @job.last_build
|
13
12
|
end
|
14
13
|
@revisions = {}
|
14
|
+
@xml_api_build_info_path = File.join(Hudson[:url], "job/#{@job.name}/#{@number}/api/xml")
|
15
15
|
load_build_info
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
19
19
|
def load_build_info
|
20
|
-
path = "#{HUDSON_URL_ROOT}/job/#{@job.name}/#{@number}/api/xml"
|
21
|
-
build_info_xml = get_xml(path)
|
22
|
-
build_info_doc = REXML::Document.new(build_info_xml)
|
23
20
|
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
build_info_xml = get_xml(@xml_api_build_info_path)
|
22
|
+
build_info_doc = REXML::Document.new(build_info_xml)
|
23
|
+
|
24
|
+
if !build_info_doc.elements["/freeStyleBuild/changeSet"].nil?
|
25
|
+
build_info_doc.elements.each("/freeStyleBuild/changeSet/revision"){|e| @revisions[e.elements["module"].text] = e.elements["revision"].text }
|
26
|
+
end
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -1,11 +1,16 @@
|
|
1
|
-
require 'hudson-remote-api'
|
2
1
|
module Hudson
|
3
2
|
# This class provides an interface to Hudson's build queue
|
4
3
|
class BuildQueue < HudsonObject
|
4
|
+
|
5
|
+
def self.load_xml_api
|
6
|
+
@@xml_api_build_queue_info_path = File.join(Hudson[:url], "queue/api/xml")
|
7
|
+
end
|
8
|
+
|
9
|
+
load_xml_api
|
10
|
+
|
5
11
|
# List the jobs in the queue
|
6
12
|
def self.list()
|
7
|
-
|
8
|
-
xml = get_xml(path)
|
13
|
+
xml = get_xml(@@xml_api_build_queue_info_path)
|
9
14
|
queue = []
|
10
15
|
queue_doc = REXML::Document.new(xml)
|
11
16
|
return queue if queue_doc.elements["/queue/item"].nil?
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/multicast.rb'
|
2
|
+
|
3
|
+
module Hudson
|
4
|
+
# set default settings
|
5
|
+
@@settings = {:url => 'http://localhost:8080', :user => nil, :password => nil, :version => nil}
|
6
|
+
|
7
|
+
def self.[](param)
|
8
|
+
return @@settings[param]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.[]=(param,value)
|
12
|
+
param = param.to_sym if param.kind_of?(String)
|
13
|
+
if param == :host or param == :url
|
14
|
+
value = "http://#{value}" if value !~ /https?:\/\//
|
15
|
+
@@settings[:url] = value
|
16
|
+
else
|
17
|
+
@@settings[param]=value
|
18
|
+
end
|
19
|
+
HudsonObject::load_xml_api
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.settings=(settings)
|
23
|
+
if settings.kind_of?(Hash)
|
24
|
+
settings.each do |param, value|
|
25
|
+
Hudson[param] = value
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Discovers nearby Hudson server on the network and configures settings
|
31
|
+
def self.auto_config
|
32
|
+
xml_response = discover()
|
33
|
+
if xml_response
|
34
|
+
#puts xml_response
|
35
|
+
doc = REXML::Document.new(xml_response)
|
36
|
+
url = doc.elements["/hudson/url"]
|
37
|
+
if url
|
38
|
+
Hudson[:url] = url.text
|
39
|
+
Hudson[:version] = doc.elements["/hudson/version"].text
|
40
|
+
puts "found Hudson version #{Hudson[:version]} @ #{Hudson[:url]}"
|
41
|
+
return true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'hudson-remote-api'
|
2
1
|
module Hudson
|
3
2
|
# This class provides an interface to Hudson jobs
|
4
3
|
class Job < HudsonObject
|
@@ -8,8 +7,7 @@ module Hudson
|
|
8
7
|
|
9
8
|
# List all Hudson jobs
|
10
9
|
def self.list()
|
11
|
-
|
12
|
-
xml = get_xml(path)
|
10
|
+
xml = get_xml(@@hudson_xml_api_path)
|
13
11
|
|
14
12
|
jobs = []
|
15
13
|
jobs_doc = REXML::Document.new(xml)
|
@@ -21,8 +19,7 @@ module Hudson
|
|
21
19
|
|
22
20
|
# List all jobs in active execution
|
23
21
|
def self.list_active
|
24
|
-
|
25
|
-
xml = get_xml(path)
|
22
|
+
xml = get_xml(@@hudson_xml_api_path)
|
26
23
|
|
27
24
|
active_jobs = []
|
28
25
|
jobs_doc = REXML::Document.new(xml)
|
@@ -36,14 +33,24 @@ module Hudson
|
|
36
33
|
|
37
34
|
def initialize(name)
|
38
35
|
@name = name
|
36
|
+
load_xml_api
|
39
37
|
load_config
|
40
38
|
load_info
|
41
39
|
end
|
42
40
|
|
41
|
+
def load_xml_api
|
42
|
+
@xml_api_path = File.join(Hudson[:url], "job/#{@name}/api/xml")
|
43
|
+
@xml_api_config_path = File.join(Hudson[:url], "job/#{@name}/config.xml")
|
44
|
+
@xml_api_build_path = File.join(Hudson[:url], "job/#{@name}/build")
|
45
|
+
@xml_api_disable_path = File.join(Hudson[:url], "job/#{@name}/disable")
|
46
|
+
@xml_api_enable_path = File.join(Hudson[:url], "job/#{@name}/enable")
|
47
|
+
@xml_api_delete_path = File.join(Hudson[:url], "job/#{@name}/doDelete")
|
48
|
+
@xml_api_wipe_out_workspace_path = File.join(Hudson[:url], "job/#{@name}/doWipeOutWorkspace")
|
49
|
+
end
|
50
|
+
|
43
51
|
# Load data from Hudson's Job configuration settings into class variables
|
44
52
|
def load_config()
|
45
|
-
|
46
|
-
@config = get_xml(path)
|
53
|
+
@config = get_xml(@xml_api_config_path)
|
47
54
|
@config_doc = REXML::Document.new(@config)
|
48
55
|
|
49
56
|
@config_doc = REXML::Document.new(@config)
|
@@ -61,19 +68,19 @@ module Hudson
|
|
61
68
|
end
|
62
69
|
|
63
70
|
def load_info()
|
64
|
-
|
65
|
-
@info = get_xml(path)
|
71
|
+
@info = get_xml(@xml_api_path)
|
66
72
|
@info_doc = REXML::Document.new(@info)
|
67
73
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
if @info_doc.elements["/freeStylePorject"]
|
75
|
+
@color = @info_doc.elements["/freeStyleProject/color"].text if @info_doc.elements["/freeStyleProject/color"]
|
76
|
+
@last_build = @info_doc.elements["/freeStyleProject/lastBuild/number"].text if @info_doc.elements["/freeStyleProject/lastBuild/number"]
|
77
|
+
@last_completed_build = @info_doc.elements["/freeStyleProject/lastCompletedBuild/number"].text if @info_doc.elements["/freeStyleProject/lastCompletedBuild/number"]
|
78
|
+
@last_failed_build = @info_doc.elements["/freeStyleProject/lastFailedBuild/number"].text if @info_doc.elements["/freeStyleProject/lastFailedBuild/number"]
|
79
|
+
@last_stable_build = @info_doc.elements["/freeStyleProject/lastStableBuild/number"].text if @info_doc.elements["/freeStyleProject/lastStableBuild/number"]
|
80
|
+
@last_successful_build = @info_doc.elements["/freeStyleProject/lastSuccessfulBuild/number"].text if @info_doc.elements["/freeStyleProject/lastSuccessfulBuild/number"]
|
81
|
+
@last_unsuccessful_build = @info_doc.elements["/freeStyleProject/lastUnsuccessfulBuild/number"].text if @info_doc.elements["/freeStyleProject/lastUnsuccessfulBuild/number"]
|
82
|
+
@next_build_number = @info_doc.elements["/freeStyleProject/nextBuildNumber"].text if @info_doc.elements["/freeStyleProject/nextBuildNumber"]
|
83
|
+
end
|
77
84
|
end
|
78
85
|
|
79
86
|
def active?
|
@@ -91,9 +98,8 @@ module Hudson
|
|
91
98
|
# Create a new job on Hudson server based on the current job object
|
92
99
|
def copy(new_job=nil)
|
93
100
|
new_job = "copy_of_#{@name}" if new_job.nil?
|
94
|
-
path = "#{HUDSON_URL_ROOT}/createItem"
|
95
101
|
|
96
|
-
response = send_post_request(
|
102
|
+
response = send_post_request(@@xml_api_create_item_path, {:name=>new_job, :mode=>"copy", :from=>@name})
|
97
103
|
raise(APIError, "Error copying job #{@name}: #{response.body}") if response.class != Net::HTTPFound
|
98
104
|
Job.new(new_job)
|
99
105
|
end
|
@@ -101,8 +107,7 @@ module Hudson
|
|
101
107
|
# Update the job configuration on Hudson server
|
102
108
|
def update(config=nil)
|
103
109
|
@config = config if !config.nil?
|
104
|
-
|
105
|
-
response = send_xml_post_request(path, @config)
|
110
|
+
response = send_xml_post_request(@xml_api_config_path, @config)
|
106
111
|
response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
|
107
112
|
end
|
108
113
|
|
@@ -147,37 +152,33 @@ module Hudson
|
|
147
152
|
|
148
153
|
# Start building this job on Hudson server (can't build parameterized jobs)
|
149
154
|
def build()
|
150
|
-
|
151
|
-
response = send_post_request(path, {:delay => '0sec'})
|
155
|
+
response = send_post_request(@xml_api_build_path, {:delay => '0sec'})
|
152
156
|
response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
|
153
157
|
end
|
154
158
|
|
155
|
-
def disable()
|
156
|
-
|
157
|
-
response = send_post_request(path)
|
159
|
+
def disable()
|
160
|
+
response = send_post_request(@xml_api_disable_path)
|
158
161
|
puts response.class
|
159
162
|
response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
|
160
163
|
end
|
161
164
|
|
162
|
-
def enable()
|
163
|
-
|
164
|
-
response = send_post_request(path)
|
165
|
+
def enable()
|
166
|
+
response = send_post_request(@xml_api_enable_path)
|
165
167
|
puts response.class
|
166
168
|
response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
|
167
169
|
end
|
168
170
|
|
169
171
|
# Delete this job from Hudson server
|
170
172
|
def delete()
|
171
|
-
|
172
|
-
response = send_post_request(path)
|
173
|
+
response = send_post_request(@xml_api_delete_path)
|
173
174
|
response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
|
174
175
|
end
|
175
176
|
|
176
177
|
def wipe_out_workspace()
|
177
178
|
wait_for_build_to_finish
|
178
|
-
|
179
|
+
|
179
180
|
if !active?
|
180
|
-
response = send_post_request(
|
181
|
+
response = send_post_request(@xml_api_wipe_out_workspace_path)
|
181
182
|
else
|
182
183
|
response = false
|
183
184
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'timeout'
|
3
|
+
require 'rexml/document'
|
4
|
+
|
5
|
+
module Hudson
|
6
|
+
def self.discover(multicast_addr = "239.77.124.213", port=33848, timeout_limit=5)
|
7
|
+
socket = UDPSocket.open
|
8
|
+
socket.setsockopt(Socket::IPPROTO_IP, Socket::IP_TTL, [1].pack('i'))
|
9
|
+
socket.send(ARGV.join(' '), 0, multicast_addr, port)
|
10
|
+
msg = nil
|
11
|
+
#msg, info = socket.recvfrom_nonblock(1024)
|
12
|
+
timeout(timeout_limit) do
|
13
|
+
msg, info = socket.recvfrom(1024)
|
14
|
+
end
|
15
|
+
msg
|
16
|
+
rescue Exception => e
|
17
|
+
puts e
|
18
|
+
nil
|
19
|
+
ensure
|
20
|
+
socket.close
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
$LOAD_PATH << File.dirname(__FILE__) + "/../lib"
|
3
|
+
require 'hudson-remote-api.rb'
|
4
|
+
|
5
|
+
class TestHudsonBuild < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_init
|
8
|
+
# TODO: load hudson build fixtures
|
9
|
+
#assert Hudson::Build.new('test_job')
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
$LOAD_PATH << File.dirname(__FILE__) + "/../lib"
|
3
|
+
require 'hudson-remote-api.rb'
|
4
|
+
|
5
|
+
class TestHudsonConfig < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_get
|
8
|
+
assert Hudson[:url]
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_set
|
12
|
+
test_url = "test.host.com"
|
13
|
+
Hudson[:url] = test_url
|
14
|
+
assert_equal(Hudson[:url], "http://#{test_url}")
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_load_settings_hash
|
18
|
+
new_settings = {:url => 'test.com', :user => 'test', :password => 'test', :version => '1.00'}
|
19
|
+
Hudson.settings = new_settings
|
20
|
+
assert_equal(Hudson[:url], "http://#{new_settings[:url]}")
|
21
|
+
assert_equal(Hudson[:user], "test")
|
22
|
+
assert_equal(Hudson[:password], "test")
|
23
|
+
assert_equal(Hudson[:version], "1.00")
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_auto_config
|
27
|
+
assert_nothing_thrown{ Hudson.auto_config }
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
$LOAD_PATH << File.dirname(__FILE__) + "/../lib"
|
3
|
+
require 'hudson-remote-api.rb'
|
4
|
+
|
5
|
+
class TestHudsonJob < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def test_list
|
8
|
+
assert Hudson::Job.list
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_list_active
|
12
|
+
assert Hudson::Job.list_active
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_init
|
16
|
+
# TODO: load job fixtures
|
17
|
+
#assert Hudson::Job.new('test_job')
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hudson-remote-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 2
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dru Ibarra
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-03 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -26,9 +26,11 @@ executables: []
|
|
26
26
|
extensions: []
|
27
27
|
|
28
28
|
extra_rdoc_files:
|
29
|
+
- LICENSE
|
29
30
|
- README
|
30
31
|
files:
|
31
32
|
- .gitignore
|
33
|
+
- LICENSE
|
32
34
|
- README
|
33
35
|
- Rakefile
|
34
36
|
- VERSION
|
@@ -36,8 +38,16 @@ files:
|
|
36
38
|
- lib/hudson-remote-api.rb
|
37
39
|
- lib/hudson-remote-api/build.rb
|
38
40
|
- lib/hudson-remote-api/build_queue.rb
|
41
|
+
- lib/hudson-remote-api/config.rb
|
39
42
|
- lib/hudson-remote-api/errors.rb
|
40
43
|
- lib/hudson-remote-api/job.rb
|
44
|
+
- lib/hudson-remote-api/multicast.rb
|
45
|
+
- test/test_hudson_build.rb
|
46
|
+
- test/test_hudson_build_queue.rb
|
47
|
+
- test/test_hudson_config.rb
|
48
|
+
- test/test_hudson_job.rb
|
49
|
+
- test/test_hudson_multicast.rb
|
50
|
+
- test/test_hudson_remote_api.rb
|
41
51
|
has_rdoc: true
|
42
52
|
homepage: http://github.com/Druwerd/hudson-remote-api
|
43
53
|
licenses: []
|
@@ -72,5 +82,10 @@ rubygems_version: 1.3.7
|
|
72
82
|
signing_key:
|
73
83
|
specification_version: 3
|
74
84
|
summary: Connect to Hudson's remote web API
|
75
|
-
test_files:
|
76
|
-
|
85
|
+
test_files:
|
86
|
+
- test/test_hudson_build.rb
|
87
|
+
- test/test_hudson_build_queue.rb
|
88
|
+
- test/test_hudson_config.rb
|
89
|
+
- test/test_hudson_job.rb
|
90
|
+
- test/test_hudson_multicast.rb
|
91
|
+
- test/test_hudson_remote_api.rb
|