hudson-remote-api 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +175 -0
- data/lib/hudson-remote-api/job.rb +14 -4
- metadata +42 -15
- data/README +0 -50
- data/Rakefile +0 -26
- data/VERSION +0 -1
- data/hudson-remote-api.gemspec +0 -54
- data/test/test_hudson_build.rb +0 -26
- data/test/test_hudson_build_queue.rb +0 -16
- data/test/test_hudson_config.rb +0 -37
- data/test/test_hudson_job.rb +0 -118
- data/test/test_hudson_multicast.rb +0 -11
data/README.md
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
[![Build Status](https://secure.travis-ci.org/Druwerd/hudson-remote-api.png)](http://travis-ci.org/Druwerd/hudson-remote-api)
|
2
|
+
# hudson-remote-api
|
3
|
+
hudson-remote-api is ruby library to talk to Hudson's xml remote access api
|
4
|
+
|
5
|
+
## Installation:
|
6
|
+
|
7
|
+
gem install hudson-remote-api
|
8
|
+
|
9
|
+
## Configuration:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
require 'hudson-remote-api'
|
13
|
+
```
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
# Auto Configuration
|
17
|
+
# detects Hudson instance on your network & sets Hudson[:url]
|
18
|
+
Hudson.auto_config
|
19
|
+
```
|
20
|
+
Or
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
# Manual Configuration
|
24
|
+
Hudson[:url] = 'http://localhost:8080'
|
25
|
+
Hudson[:user] = 'hudson'
|
26
|
+
Hudson[:password] = 'password'
|
27
|
+
|
28
|
+
# To turn off checking for crumbIssuer
|
29
|
+
Hudson[:crumb] = false
|
30
|
+
```
|
31
|
+
## Usage:
|
32
|
+
|
33
|
+
### List jobs
|
34
|
+
```ruby
|
35
|
+
# list all jobs
|
36
|
+
Hudson::Job.list
|
37
|
+
|
38
|
+
# list current active jobs
|
39
|
+
Hudson::Job.list_active
|
40
|
+
```
|
41
|
+
|
42
|
+
### Build Queue
|
43
|
+
```ruby
|
44
|
+
# list all jobs in the build queue (waiting to run)
|
45
|
+
Hudson::BuildQueue.list
|
46
|
+
```
|
47
|
+
|
48
|
+
### Create (or load existing) job
|
49
|
+
```ruby
|
50
|
+
j = Hudson::Job.new('my_new_job')
|
51
|
+
```
|
52
|
+
|
53
|
+
### Actions on a job
|
54
|
+
```ruby
|
55
|
+
j = Hudson::Job.new('my_new_job')
|
56
|
+
|
57
|
+
# start a build
|
58
|
+
j.build
|
59
|
+
|
60
|
+
# start a parameterized build. Pass parameters as a Hash.
|
61
|
+
j.build({ :awesome_dev => "thomasbiddle" })
|
62
|
+
|
63
|
+
# create a copy of existing job
|
64
|
+
j.copy('copy_of_my_job')
|
65
|
+
|
66
|
+
# disable the job
|
67
|
+
j.disable
|
68
|
+
|
69
|
+
# enable the job
|
70
|
+
j.enable
|
71
|
+
|
72
|
+
# clear out the job's workspace
|
73
|
+
j.wipe_out_workspace
|
74
|
+
|
75
|
+
# wait (sleep) until the job has completed building
|
76
|
+
j.wait_for_build_to_finish
|
77
|
+
|
78
|
+
# delete the job
|
79
|
+
j.delete
|
80
|
+
```
|
81
|
+
|
82
|
+
### Information on a job
|
83
|
+
```ruby
|
84
|
+
j = Hudson::Job.new('job_name')
|
85
|
+
|
86
|
+
# the job's URL address on Hudson server
|
87
|
+
puts j.url
|
88
|
+
|
89
|
+
# job's current build indicator color
|
90
|
+
puts j.color
|
91
|
+
|
92
|
+
# returns true if job is currently running
|
93
|
+
j.active?
|
94
|
+
|
95
|
+
# list of job's build numbers
|
96
|
+
puts j.builds_list
|
97
|
+
|
98
|
+
# latest build number
|
99
|
+
puts j.last_build
|
100
|
+
|
101
|
+
# latest successful build number
|
102
|
+
puts j.last_successful_build
|
103
|
+
|
104
|
+
# latest failed build number
|
105
|
+
puts j.last_failed_build
|
106
|
+
|
107
|
+
# next build number
|
108
|
+
puts j.next_build_number
|
109
|
+
|
110
|
+
# view current triggers
|
111
|
+
# returns hash containing trigger name in key and trigger spec in value.
|
112
|
+
# Example: {"hudson.triggers.TimerTrigger"=>"0 22 * * *", "hudson.triggers.SCMTrigger"=>"* * * * *"}
|
113
|
+
j.triggers
|
114
|
+
```
|
115
|
+
|
116
|
+
### Information on a build
|
117
|
+
```ruby
|
118
|
+
# gets information on latest build
|
119
|
+
b = Hudson::Build.new('job_name')
|
120
|
+
|
121
|
+
# gets information on particular build number
|
122
|
+
b = Hudson::Build.new('job_name', 42)
|
123
|
+
|
124
|
+
# get commit revisions in this build
|
125
|
+
puts b.revisions
|
126
|
+
|
127
|
+
# get the result of this build
|
128
|
+
puts b.result
|
129
|
+
|
130
|
+
# get the culprit of this build
|
131
|
+
puts b.culprit
|
132
|
+
```
|
133
|
+
|
134
|
+
### Modifying a job
|
135
|
+
|
136
|
+
#### Set job description
|
137
|
+
```ruby
|
138
|
+
j.description = "My new job description"
|
139
|
+
```
|
140
|
+
|
141
|
+
#### Set repository
|
142
|
+
```ruby
|
143
|
+
# Git
|
144
|
+
j.repository_url = { :url => 'https://github.com/beeplove/hudson-remote-api-mkhan.git', :branch => 'origin/master' }
|
145
|
+
# or, only to change branch
|
146
|
+
j.repository_url = { :branch => 'origin/master' }
|
147
|
+
|
148
|
+
# SVN
|
149
|
+
j.repository_url = "http://svn.myrepo.com"
|
150
|
+
```
|
151
|
+
|
152
|
+
#### Set build triggers
|
153
|
+
```ruby
|
154
|
+
j.triggers = { 'hudson.triggers.SCMTrigger' => '* * * * *'}
|
155
|
+
# or, using shortcut
|
156
|
+
j.triggers = { 'SCMTrigger' => '* * * * *', 'TimerTrigger' => '0 22 * * *'}
|
157
|
+
|
158
|
+
# Add or update a trigger in existing triggers*
|
159
|
+
j.triggers = j.triggers.merge({ 'hudson.triggers.TimerTrigger' => '0 22 * * *'})
|
160
|
+
|
161
|
+
# Delete existing triggers
|
162
|
+
j.triggers = {}
|
163
|
+
# or,
|
164
|
+
j.triggers = nil
|
165
|
+
|
166
|
+
```
|
167
|
+
*Avoid using shortcut form when editing a trigger in existing triggers
|
168
|
+
|
169
|
+
## Contributing
|
170
|
+
|
171
|
+
1. Fork it
|
172
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
173
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
174
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
175
|
+
5. Create new Pull Request
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Hudson
|
2
2
|
# This class provides an interface to Hudson jobs
|
3
3
|
class Job < HudsonObject
|
4
|
-
attr_accessor :name, :config, :repository_url, :repository_urls, :repository_browser_location, :description
|
4
|
+
attr_accessor :name, :config, :repository_url, :repository_urls, :repository_browser_location, :description, :parameterized_job
|
5
5
|
|
6
6
|
SVN_SCM_CONF = <<-SVN_SCM_STRING
|
7
7
|
<scm class="hudson.scm.SubversionSCM">
|
@@ -78,6 +78,7 @@ SVN_SCM_STRING
|
|
78
78
|
@xml_api_path = File.join(Hudson[:url], "job/#{@name}/api/xml")
|
79
79
|
@xml_api_config_path = File.join(Hudson[:url], "job/#{@name}/config.xml")
|
80
80
|
@xml_api_build_path = File.join(Hudson[:url], "job/#{@name}/build")
|
81
|
+
@xml_api_build_with_params_path = File.join(Hudson[:url], "job/#{@name}/buildWithParameters")
|
81
82
|
@xml_api_disable_path = File.join(Hudson[:url], "job/#{@name}/disable")
|
82
83
|
@xml_api_enable_path = File.join(Hudson[:url], "job/#{@name}/enable")
|
83
84
|
@xml_api_delete_path = File.join(Hudson[:url], "job/#{@name}/doDelete")
|
@@ -97,6 +98,11 @@ SVN_SCM_STRING
|
|
97
98
|
@description = @config_doc.elements["/project/description"].text || ""
|
98
99
|
end
|
99
100
|
|
101
|
+
@parameterized_job = false
|
102
|
+
if @config_doc.elements["/project/properties/hudson.model.ParametersDefinitionProperty"]
|
103
|
+
@parameterized_job = true
|
104
|
+
end
|
105
|
+
|
100
106
|
if @config_doc.elements["/project/scm"].attributes['class'] == "hudson.plugins.git.GitSCM"
|
101
107
|
@git = true
|
102
108
|
@repository_url = {}
|
@@ -302,9 +308,13 @@ SVN_SCM_STRING
|
|
302
308
|
File.join( Hudson[:url], 'job', name) + '/'
|
303
309
|
end
|
304
310
|
|
305
|
-
# Start building this job on Hudson server
|
306
|
-
def build()
|
307
|
-
|
311
|
+
# Start building this job on Hudson server
|
312
|
+
def build(params={})
|
313
|
+
if @parameterized_job
|
314
|
+
response = send_post_request(@xml_api_build_with_params_path, {:delay => '0sec'}.merge(params))
|
315
|
+
else
|
316
|
+
response = send_post_request(@xml_api_build_path, {:delay => '0sec'})
|
317
|
+
end
|
308
318
|
response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
|
309
319
|
end
|
310
320
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hudson-remote-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,21 +9,48 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
12
|
+
date: 2013-06-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: jeweler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
14
46
|
description: Connect to Hudson's remote web API
|
15
47
|
email: Druwerd@gmail.com
|
16
48
|
executables: []
|
17
49
|
extensions: []
|
18
50
|
extra_rdoc_files:
|
19
51
|
- LICENSE
|
20
|
-
- README
|
52
|
+
- README.md
|
21
53
|
files:
|
22
|
-
- LICENSE
|
23
|
-
- README
|
24
|
-
- Rakefile
|
25
|
-
- VERSION
|
26
|
-
- hudson-remote-api.gemspec
|
27
54
|
- lib/hudson-remote-api.rb
|
28
55
|
- lib/hudson-remote-api/build.rb
|
29
56
|
- lib/hudson-remote-api/build_queue.rb
|
@@ -32,11 +59,8 @@ files:
|
|
32
59
|
- lib/hudson-remote-api/job.rb
|
33
60
|
- lib/hudson-remote-api/multicast.rb
|
34
61
|
- lib/hudson-remote-api/new_job_config.xml
|
35
|
-
-
|
36
|
-
-
|
37
|
-
- test/test_hudson_config.rb
|
38
|
-
- test/test_hudson_job.rb
|
39
|
-
- test/test_hudson_multicast.rb
|
62
|
+
- LICENSE
|
63
|
+
- README.md
|
40
64
|
homepage: http://github.com/Druwerd/hudson-remote-api
|
41
65
|
licenses: []
|
42
66
|
post_install_message:
|
@@ -49,6 +73,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
49
73
|
- - ! '>='
|
50
74
|
- !ruby/object:Gem::Version
|
51
75
|
version: '0'
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
hash: 651736009942463285
|
52
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
80
|
none: false
|
54
81
|
requirements:
|
@@ -57,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
84
|
version: '0'
|
58
85
|
requirements: []
|
59
86
|
rubyforge_project: hudson-remote-api
|
60
|
-
rubygems_version: 1.8.
|
87
|
+
rubygems_version: 1.8.25
|
61
88
|
signing_key:
|
62
89
|
specification_version: 3
|
63
90
|
summary: Connect to Hudson's remote web API
|
data/README
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
hudson-remote-api is ruby library to talk to Hudson's xml remote access api
|
2
|
-
|
3
|
-
Usage:
|
4
|
-
|
5
|
-
require 'hudson-remote-api'
|
6
|
-
|
7
|
-
# Auto Configuration sets Hudson[:url]
|
8
|
-
Hudson.auto_config
|
9
|
-
|
10
|
-
# Manual Configuration
|
11
|
-
Hudson[:url] = 'http://localhost:8080'
|
12
|
-
Hudson[:user] = 'hudson'
|
13
|
-
Hudson[:password] = 'password'
|
14
|
-
|
15
|
-
# To turn off checking for crumbIssuer
|
16
|
-
Hudson[:crumb] = false
|
17
|
-
|
18
|
-
# List all Hudson jobs
|
19
|
-
Hudson::Job.list
|
20
|
-
|
21
|
-
# List all active Hudson jobs
|
22
|
-
Hudson::Job.list_active
|
23
|
-
|
24
|
-
# print the last build number of a job
|
25
|
-
j = Hudson::Job.new('jobname')
|
26
|
-
puts j.last_build
|
27
|
-
|
28
|
-
# if you are using hudson.plugins.git.GitSCM
|
29
|
-
j.repository_url = { :url => 'https://github.com/beeplove/hudson-remote-api-mkhan.git', :branch => 'origin/master' }
|
30
|
-
# or, only to change branch
|
31
|
-
j.repository_url = { :branch => 'origin/master' }
|
32
|
-
|
33
|
-
# Set build trigger
|
34
|
-
j.triggers = { 'hudson.triggers.SCMTrigger' => '* * * * *'}
|
35
|
-
# or, using shortcut
|
36
|
-
j.triggers = { 'SCMTrigger' => '* * * * *', 'TimerTrigger' => '0 22 * * *'}
|
37
|
-
|
38
|
-
# To add or update a trigger in existing triggers
|
39
|
-
j.triggers = j.triggers.merge({ 'hudson.triggers.TimerTrigger' => '0 22 * * *'})
|
40
|
-
# Avoid using shortcut form when to edit a trigger in existing triggers
|
41
|
-
|
42
|
-
# To delete existing triggers
|
43
|
-
j.triggers = {}
|
44
|
-
# or,
|
45
|
-
j.triggers = nil
|
46
|
-
|
47
|
-
# To view current trigger
|
48
|
-
j.triggers
|
49
|
-
# would return hash containing trigger name in key and trigger spec in value.
|
50
|
-
# Example of returned hash: {"hudson.triggers.TimerTrigger"=>"0 22 * * *", "hudson.triggers.SCMTrigger"=>"* * * * *"}
|
data/Rakefile
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'rake/testtask'
|
4
|
-
|
5
|
-
begin
|
6
|
-
require 'jeweler'
|
7
|
-
Jeweler::Tasks.new do |gemspec|
|
8
|
-
gemspec.name = "hudson-remote-api"
|
9
|
-
gemspec.summary = "Connect to Hudson's remote web API"
|
10
|
-
gemspec.description = "Connect to Hudson's remote web API"
|
11
|
-
gemspec.email = "Druwerd@gmail.com"
|
12
|
-
gemspec.homepage = "http://github.com/Druwerd/hudson-remote-api"
|
13
|
-
gemspec.authors = ["Dru Ibarra"]
|
14
|
-
gemspec.rubyforge_project = gemspec.name
|
15
|
-
end
|
16
|
-
Jeweler::GemcutterTasks.new
|
17
|
-
rescue LoadError
|
18
|
-
puts "Jeweler not available. Install it with: sudo gem install jeweler -s http://gemcutter.org"
|
19
|
-
end
|
20
|
-
|
21
|
-
Rake::TestTask.new do |t|
|
22
|
-
t.libs << 'test'
|
23
|
-
end
|
24
|
-
|
25
|
-
desc "Run tests"
|
26
|
-
task :default => :test
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.6.0
|
data/hudson-remote-api.gemspec
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = "hudson-remote-api"
|
8
|
-
s.version = "0.6.0"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Dru Ibarra"]
|
12
|
-
s.date = "2012-07-14"
|
13
|
-
s.description = "Connect to Hudson's remote web API"
|
14
|
-
s.email = "Druwerd@gmail.com"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
"LICENSE",
|
21
|
-
"README",
|
22
|
-
"Rakefile",
|
23
|
-
"VERSION",
|
24
|
-
"hudson-remote-api.gemspec",
|
25
|
-
"lib/hudson-remote-api.rb",
|
26
|
-
"lib/hudson-remote-api/build.rb",
|
27
|
-
"lib/hudson-remote-api/build_queue.rb",
|
28
|
-
"lib/hudson-remote-api/config.rb",
|
29
|
-
"lib/hudson-remote-api/errors.rb",
|
30
|
-
"lib/hudson-remote-api/job.rb",
|
31
|
-
"lib/hudson-remote-api/multicast.rb",
|
32
|
-
"lib/hudson-remote-api/new_job_config.xml",
|
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
|
-
]
|
39
|
-
s.homepage = "http://github.com/Druwerd/hudson-remote-api"
|
40
|
-
s.require_paths = ["lib"]
|
41
|
-
s.rubyforge_project = "hudson-remote-api"
|
42
|
-
s.rubygems_version = "1.8.24"
|
43
|
-
s.summary = "Connect to Hudson's remote web API"
|
44
|
-
|
45
|
-
if s.respond_to? :specification_version then
|
46
|
-
s.specification_version = 3
|
47
|
-
|
48
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
-
else
|
50
|
-
end
|
51
|
-
else
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
data/test/test_hudson_build.rb
DELETED
@@ -1,26 +0,0 @@
|
|
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 setup
|
8
|
-
assert Hudson::Job.new('test_job').build
|
9
|
-
assert Hudson::Build.new('test_job')
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_build_info
|
13
|
-
build = Hudson::Build.new('test_job')
|
14
|
-
assert_equal 'test_job', build.job.name
|
15
|
-
|
16
|
-
assert build.number.to_i > 0, "build number test failed"
|
17
|
-
|
18
|
-
assert build.revisions, "build revisions test failed"
|
19
|
-
assert build.revisions.kind_of?(Hash), "build revisions is not an Hash"
|
20
|
-
|
21
|
-
assert_equal "SUCCESS", build.result, "build result test failed"
|
22
|
-
|
23
|
-
assert_nil build.culprit, "build culprit test failed"
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
$LOAD_PATH << File.dirname(__FILE__) + "/../lib"
|
3
|
-
require 'hudson-remote-api.rb'
|
4
|
-
|
5
|
-
class TestHudsonBuildQueue < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def test_list
|
8
|
-
assert Hudson::BuildQueue.list
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_load_xml_api
|
12
|
-
Hudson[:url] = "test.host.com"
|
13
|
-
assert_equal("http://test.host.com/queue/api/xml",
|
14
|
-
Hudson::BuildQueue.__send__("class_variable_get", "@@xml_api_build_queue_info_path"))
|
15
|
-
end
|
16
|
-
end
|
data/test/test_hudson_config.rb
DELETED
@@ -1,37 +0,0 @@
|
|
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
|
-
assert_equal(Hudson[:crumb], true)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_auto_config
|
28
|
-
assert_nothing_thrown{ Hudson.auto_config }
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_when_crumb_is_false
|
32
|
-
new_settings = {:url => 'test.com', :user => 'test', :password => 'test', :version => '1.00', :crumb => false}
|
33
|
-
Hudson.settings = new_settings
|
34
|
-
assert_equal(Hudson[:crumb], false)
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
data/test/test_hudson_job.rb
DELETED
@@ -1,118 +0,0 @@
|
|
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
|
-
TEST_SVN_REPO_URL = "http://svn.apache.org/repos/asf/subversion/trunk/doc/user/"
|
7
|
-
|
8
|
-
def setup
|
9
|
-
Hudson[:url] = "http://localhost:8080"
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_list
|
13
|
-
assert Hudson::Job.list
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_list_active
|
17
|
-
assert Hudson::Job.list_active
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_create
|
21
|
-
new_job_name = 'new_test_job'
|
22
|
-
new_job = Hudson::Job.create(new_job_name)
|
23
|
-
assert new_job
|
24
|
-
assert_equal(new_job.name, new_job_name)
|
25
|
-
assert_equal(true, new_job.triggers.empty?, "New job should have empty triggers")
|
26
|
-
assert new_job.delete
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_get
|
30
|
-
job = Hudson::Job.get('test_job')
|
31
|
-
assert job
|
32
|
-
assert_equal 'test_job', job.name, "failed to get job name"
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_desc_update
|
36
|
-
job = Hudson::Job.new('test_job')
|
37
|
-
assert job.description = "test"
|
38
|
-
assert job.description != nil, "Job description should not be nil"
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_scm_url
|
42
|
-
job = Hudson::Job.new('test_svn_job')
|
43
|
-
job.build
|
44
|
-
assert job.repository_url = TEST_SVN_REPO_URL
|
45
|
-
|
46
|
-
job = Hudson::Job.new('test_svn_job')
|
47
|
-
assert_equal TEST_SVN_REPO_URL, job.repository_url
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_new
|
51
|
-
job = Hudson::Job.new('test_job')
|
52
|
-
assert job
|
53
|
-
assert_equal(job.name, 'test_job')
|
54
|
-
|
55
|
-
new_job = Hudson::Job.new('test_job2')
|
56
|
-
assert new_job
|
57
|
-
assert_equal('test_job2', new_job.name)
|
58
|
-
assert new_job.delete
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_copy
|
62
|
-
job = Hudson::Job.get('test_job')
|
63
|
-
new_job = job.copy
|
64
|
-
assert new_job
|
65
|
-
assert_equal(new_job.name, 'copy_of_test_job')
|
66
|
-
assert new_job.delete
|
67
|
-
end
|
68
|
-
|
69
|
-
def test_url
|
70
|
-
job = Hudson::Job.get("test_job")
|
71
|
-
assert_equal(job.url, "http://localhost:8080/job/#{job.name}/")
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_job_with_spaces
|
75
|
-
job = Hudson::Job.create('test job with spaces')
|
76
|
-
assert job
|
77
|
-
assert job.name
|
78
|
-
assert job.delete
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_builds_list
|
82
|
-
job = Hudson::Job.get("test_job")
|
83
|
-
assert job.builds_list.kind_of?(Array)
|
84
|
-
end
|
85
|
-
|
86
|
-
def test_triggers_set
|
87
|
-
job_name = 'build_triggers'
|
88
|
-
job = Hudson::Job.create(job_name)
|
89
|
-
|
90
|
-
job.triggers = { "hudson.triggers.SCMTrigger" => '* * * * *' }
|
91
|
-
assert_equal(1, job.triggers.size, "Failed to set triggers with 1 trigger.")
|
92
|
-
assert_equal({"hudson.triggers.SCMTrigger" => '* * * * *'}, job.triggers, "Failed to set triggers with 1 trigger.")
|
93
|
-
|
94
|
-
assert job.delete
|
95
|
-
end
|
96
|
-
|
97
|
-
def test_triggers_set_using_shortcut
|
98
|
-
job_name = 'build_triggers'
|
99
|
-
job = Hudson::Job.create(job_name)
|
100
|
-
|
101
|
-
job.triggers = { "SCMTrigger" => '* * * * *', 'TimerTrigger' => '0 22 * * *' }
|
102
|
-
assert_equal(2, job.triggers.size, "Failed to set triggers using shortcut.")
|
103
|
-
assert_equal({"hudson.triggers.SCMTrigger"=>"* * * * *", "hudson.triggers.TimerTrigger"=>"0 22 * * *"}, job.triggers, "Failed to set triggers using shortcut.")
|
104
|
-
|
105
|
-
assert job.delete
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_triggers_delete
|
109
|
-
job_name = 'build_triggers'
|
110
|
-
job = Hudson::Job.create(job_name)
|
111
|
-
|
112
|
-
job.triggers = { "SCMTrigger" => '* * * * *', 'TimerTrigger' => '0 22 * * *' }
|
113
|
-
job.triggers = {}
|
114
|
-
assert_equal(true, job.triggers.empty?, "Failed to delete triggers.")
|
115
|
-
|
116
|
-
assert job.delete
|
117
|
-
end
|
118
|
-
end
|