jenkins_api_client 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +8 -5
- data/CHANGELOG.md +43 -12
- data/Gemfile +1 -1
- data/README.md +3 -0
- data/jenkins_api_client.gemspec +10 -6
- data/lib/jenkins_api_client/client.rb +38 -18
- data/lib/jenkins_api_client/job.rb +30 -1
- data/lib/jenkins_api_client/version.rb +1 -1
- data/lib/jenkins_api_client/view.rb +1 -1
- data/spec/func_tests/job_spec.rb +3 -1
- data/spec/unit_tests/client_spec.rb +25 -13
- data/travis/jenkins_config.xml +63 -0
- data/travis/setup.sh +22 -0
- data/travis/spec.yml +10 -0
- data/travis/user_config.xml +29 -0
- metadata +11 -5
data/.travis.yml
CHANGED
@@ -2,22 +2,25 @@ language: ruby
|
|
2
2
|
rvm:
|
3
3
|
- 2.0.0
|
4
4
|
- 1.9.3
|
5
|
-
- 1.9.2
|
6
5
|
- jruby-18mode
|
7
6
|
- jruby-19mode
|
8
7
|
- rbx-18mode
|
9
8
|
- rbx-19mode
|
10
|
-
- ruby-head
|
11
|
-
- jruby-head
|
12
9
|
- 1.8.7
|
13
10
|
- ree
|
14
11
|
matrix:
|
15
12
|
allow_failures:
|
16
13
|
- rvm: jruby-18mode
|
17
14
|
- rvm: jruby-19mode
|
18
|
-
- rvm:
|
15
|
+
- rvm: rbx-18mode
|
16
|
+
- rvm: rbx-19mode
|
19
17
|
- rvm: ree
|
20
|
-
|
18
|
+
before_install:
|
19
|
+
- travis/setup.sh
|
20
|
+
|
21
|
+
script:
|
22
|
+
- bundle exec rake unit_tests
|
23
|
+
- bundle exec rake func_tests
|
21
24
|
notifications:
|
22
25
|
email: false
|
23
26
|
irc:
|
data/CHANGELOG.md
CHANGED
@@ -4,9 +4,29 @@ CHANGELOG
|
|
4
4
|
upcoming
|
5
5
|
--------
|
6
6
|
|
7
|
+
v0.12.0 [18-JUN-2013]
|
8
|
+
----------------------
|
9
|
+
* Authentication is now optional as not all Jenkins instances have
|
10
|
+
authentication enabled by default. Credit: @dougforpres
|
11
|
+
* Ability to retrieve build details so that more than just (`lamp color`) is
|
12
|
+
available. Credit: @dougforpres
|
13
|
+
* Ability to retrieve build test-results for those builds that have them.
|
14
|
+
Credit: @dougforpres
|
15
|
+
* Option to follow any 301/302 responses. This allows POST to build to follow
|
16
|
+
the redirect and end up with a 200 response. Credit: @dougforpres
|
17
|
+
* Minor change to the POST requests handling where jenkins instances with a
|
18
|
+
proxy returns 411 if no form data is specified. Fixed by sending an empty
|
19
|
+
hash. Credit: @dougforpres
|
20
|
+
* As of Jenkins release 1.519, the job build returns a 201 code instead of 302.
|
21
|
+
This was resulting in an exception and the exception handling is modified to
|
22
|
+
handle this condition.
|
23
|
+
* The jobs that are not built yet have a new color (`notbuilt`) in the recent
|
24
|
+
version of jenkins (> 1.517) whih resulted in `invalid` status. This is fixed.
|
25
|
+
|
7
26
|
v0.11.0 [09-JUN-2013]
|
8
27
|
----------------------
|
9
|
-
* A new input argument `server_url` is supported which accepts the jenkins URL
|
28
|
+
* A new input argument `server_url` is supported which accepts the jenkins URL
|
29
|
+
instead of IP address and Port. Credit: @dieterdemeyer
|
10
30
|
* When renaming the job, preserve the job history. Credit: @rubytester
|
11
31
|
* Various exception handling improvements. Credit: @drnic
|
12
32
|
|
@@ -20,17 +40,21 @@ v0.10.0 [24-APR-2013]
|
|
20
40
|
|
21
41
|
v0.9.1 [01-APR-2013]
|
22
42
|
---------------------
|
23
|
-
* Removed the dependency of ActiveSupport and Builder as they were not being
|
43
|
+
* Removed the dependency of ActiveSupport and Builder as they were not being
|
44
|
+
used.
|
24
45
|
|
25
46
|
v0.9.0 [10-MAR-2013]
|
26
47
|
---------------------
|
27
48
|
* Added capability to send email notification to existing jobs
|
28
49
|
* Removed warnings from client.rb
|
29
50
|
* Refactored and improved exception handling
|
30
|
-
* A bug is fixed in client which allows only the valid params as options.
|
31
|
-
|
51
|
+
* A bug is fixed in client which allows only the valid params as options.
|
52
|
+
Credit: @Niarfe
|
53
|
+
* Added a timeout parameter for waiting for jenkins to become ready.
|
54
|
+
Credit: @Niarfe
|
32
55
|
* Added function to reload jenkins. Credit: @missedone
|
33
|
-
* Fixed a bug where jenkins_path was missing in get_config and post_config.
|
56
|
+
* Fixed a bug where jenkins_path was missing in get_config and post_config.
|
57
|
+
Credit: @cylol
|
34
58
|
* Added capability to obtain jenkins version and other useful information
|
35
59
|
* Added new tests for various cases, and other code improvements
|
36
60
|
|
@@ -42,7 +66,8 @@ v0.8.0 [14-FEB-2013]
|
|
42
66
|
---------------------
|
43
67
|
* Added capability to send timer trigger while creating a job
|
44
68
|
* Added rename feature for jobs
|
45
|
-
* Added support for sending skype notification in job creation and on existing
|
69
|
+
* Added support for sending skype notification in job creation and on existing
|
70
|
+
jobs
|
46
71
|
* Added support for sending Jenkins root URL configuration. Credit: @kevinhcross
|
47
72
|
* Added `delete_all!` methods for Job, View, and Node.
|
48
73
|
* `get_eta` in BuildQueue will return "N/A" if the ETA is not given by Jenkins
|
@@ -52,7 +77,8 @@ v0.8.0 [14-FEB-2013]
|
|
52
77
|
|
53
78
|
v0.7.3 [05-FEB-2013]
|
54
79
|
---------------------
|
55
|
-
* Fixed #27 with a bug in create_view including extra character in the end of
|
80
|
+
* Fixed #27 with a bug in create_view including extra character in the end of
|
81
|
+
the name
|
56
82
|
|
57
83
|
v0.7.2 [02-FEB-2013]
|
58
84
|
---------------------
|
@@ -76,24 +102,29 @@ v0.7.0 [27-JAN-2013]
|
|
76
102
|
|
77
103
|
v0.6.2 [13-JAN-2013]
|
78
104
|
---------------------
|
79
|
-
* Fixed a bug where running job previously aborted was not recognized by the
|
105
|
+
* Fixed a bug where running job previously aborted was not recognized by the
|
106
|
+
color
|
80
107
|
|
81
108
|
v0.6.1 [13-JAN-2013]
|
82
109
|
---------------------
|
83
|
-
* Fixed a bug where the last few lines of console output was missed in the CLI
|
110
|
+
* Fixed a bug where the last few lines of console output was missed in the CLI
|
111
|
+
when using the `jenkinscli job console` command.
|
84
112
|
|
85
113
|
v0.6.0 [12-JAN-2013]
|
86
114
|
---------------------
|
87
115
|
* Added functionality to get progressive console output from Jenkins.
|
88
|
-
* Added CLI command `console` for printing progressive console output on
|
89
|
-
|
116
|
+
* Added CLI command `console` for printing progressive console output on
|
117
|
+
terminal.
|
118
|
+
* Fixed a bug with `get_current_build_number` not returning the recent running
|
119
|
+
build number.
|
90
120
|
|
91
121
|
v0.5.0 [22-DEC-2012]
|
92
122
|
---------------------
|
93
123
|
* Added functionality to create jobs with params.
|
94
124
|
* Added View class and added methods accessing List Views of Jenkins server.
|
95
125
|
* Added functionality to abort a running job.
|
96
|
-
* Deprecated `list_running` of Job class. `list_by_status('running')` is
|
126
|
+
* Deprecated `list_running` of Job class. `list_by_status('running')` is
|
127
|
+
suggested.
|
97
128
|
|
98
129
|
v0.4.0 [07-DEC-2012]
|
99
130
|
---------------------
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -58,10 +58,13 @@ You will see the that it entered IRB session and you can play with the API clien
|
|
58
58
|
|
59
59
|
### Authentication
|
60
60
|
|
61
|
+
Supplying credentials to the client is optional, as not all Jenkins instances require authentication.
|
61
62
|
This project supports two types of password-based authentication. You can just you the plain
|
62
63
|
password by using <tt>password</tt> parameter. If you don't prefer leaving plain passwords in the
|
63
64
|
credentials file, you can encode your password in base64 format and use <tt>password_base64</tt>
|
64
65
|
parameter to specify the password either in the arguments or in the credentials file.
|
66
|
+
To use the client without credentials, just leave out the <tt>username</tt> and <tt>password</tt> parameters. The
|
67
|
+
<tt>password</tt> parameter is only required if <tt>username</tt> is specified.
|
65
68
|
|
66
69
|
### Basic Usage
|
67
70
|
|
data/jenkins_api_client.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{jenkins_api_client}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.12.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kannan Manickam"]
|
12
|
-
s.date = %q{2013-06-
|
12
|
+
s.date = %q{2013-06-19}
|
13
13
|
s.default_executable = %q{jenkinscli}
|
14
14
|
s.description = %q{
|
15
15
|
This is a simple and easy-to-use Jenkins Api client with features focused on
|
@@ -58,7 +58,11 @@ automating Job configuration programaticaly and so forth}
|
|
58
58
|
"spec/unit_tests/node_spec.rb",
|
59
59
|
"spec/unit_tests/spec_helper.rb",
|
60
60
|
"spec/unit_tests/system_spec.rb",
|
61
|
-
"spec/unit_tests/view_spec.rb"
|
61
|
+
"spec/unit_tests/view_spec.rb",
|
62
|
+
"travis/jenkins_config.xml",
|
63
|
+
"travis/setup.sh",
|
64
|
+
"travis/spec.yml",
|
65
|
+
"travis/user_config.xml"
|
62
66
|
]
|
63
67
|
s.homepage = %q{https://github.com/arangamani/jenkins_api_client}
|
64
68
|
s.require_paths = ["lib"]
|
@@ -70,7 +74,7 @@ automating Job configuration programaticaly and so forth}
|
|
70
74
|
s.specification_version = 3
|
71
75
|
|
72
76
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
73
|
-
s.add_runtime_dependency(%q<nokogiri>, ["
|
77
|
+
s.add_runtime_dependency(%q<nokogiri>, ["~> 1.5.0"])
|
74
78
|
s.add_runtime_dependency(%q<thor>, [">= 0.16.0"])
|
75
79
|
s.add_runtime_dependency(%q<json>, [">= 0"])
|
76
80
|
s.add_runtime_dependency(%q<terminal-table>, [">= 1.4.0"])
|
@@ -80,7 +84,7 @@ automating Job configuration programaticaly and so forth}
|
|
80
84
|
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
81
85
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
82
86
|
else
|
83
|
-
s.add_dependency(%q<nokogiri>, ["
|
87
|
+
s.add_dependency(%q<nokogiri>, ["~> 1.5.0"])
|
84
88
|
s.add_dependency(%q<thor>, [">= 0.16.0"])
|
85
89
|
s.add_dependency(%q<json>, [">= 0"])
|
86
90
|
s.add_dependency(%q<terminal-table>, [">= 1.4.0"])
|
@@ -91,7 +95,7 @@ automating Job configuration programaticaly and so forth}
|
|
91
95
|
s.add_dependency(%q<rspec>, [">= 0"])
|
92
96
|
end
|
93
97
|
else
|
94
|
-
s.add_dependency(%q<nokogiri>, ["
|
98
|
+
s.add_dependency(%q<nokogiri>, ["~> 1.5.0"])
|
95
99
|
s.add_dependency(%q<thor>, [">= 0.16.0"])
|
96
100
|
s.add_dependency(%q<json>, [">= 0"])
|
97
101
|
s.add_dependency(%q<terminal-table>, [">= 1.4.0"])
|
@@ -54,7 +54,8 @@ module JenkinsApi
|
|
54
54
|
"password_base64",
|
55
55
|
"debug",
|
56
56
|
"timeout",
|
57
|
-
"ssl"
|
57
|
+
"ssl",
|
58
|
+
"follow_redirects"
|
58
59
|
].freeze
|
59
60
|
|
60
61
|
# Initialize a Client object with Jenkins CI server credentials
|
@@ -63,13 +64,15 @@ module JenkinsApi
|
|
63
64
|
# * the +:server_ip+ param is the IP address of the Jenkins CI server
|
64
65
|
# * the +:server_port+ param is the port on which the Jenkins listens
|
65
66
|
# * the +:server_url+ param is the full URL address of the Jenkins CI server (http/https)
|
66
|
-
# * the +:username+ param is the username used for connecting to the server
|
67
|
-
# * the +:password+ param is the password for connecting to the CI server
|
67
|
+
# * the +:username+ param is the username used for connecting to the server (optional)
|
68
|
+
# * the +:password+ param is the password for connecting to the CI server (optional)
|
68
69
|
# * the +:proxy_ip+ param is the proxy IP address
|
69
70
|
# * the +:proxy_port+ param is the proxy port
|
70
71
|
# * the +:jenkins_path+ param is the optional context path for Jenkins
|
71
72
|
# * the +:ssl+ param indicates if Jenkins is accessible over HTTPS
|
72
73
|
# (defaults to false)
|
74
|
+
# * the +:follow_redirects+ param will cause the client to follow a redirect
|
75
|
+
# (jenkins can return a 30x when starting a build)
|
73
76
|
#
|
74
77
|
# @return [JenkinsApi::Client] a client object to Jenkins API
|
75
78
|
#
|
@@ -84,8 +87,9 @@ module JenkinsApi
|
|
84
87
|
unless @server_ip || @server_url
|
85
88
|
raise ArgumentError, "Server IP or Server URL is required to connect to Jenkins"
|
86
89
|
end
|
87
|
-
|
88
|
-
|
90
|
+
# Username/password are optional as some jenkins servers do not require auth
|
91
|
+
if @username && !(@password || @password_base64)
|
92
|
+
raise ArgumentError, "If username is provided, password is required"
|
89
93
|
end
|
90
94
|
if @proxy_ip.nil? ^ @proxy_port.nil?
|
91
95
|
raise ArgumentError, "Proxy IP and port must both be specified or" +
|
@@ -162,22 +166,38 @@ module JenkinsApi
|
|
162
166
|
# the response.
|
163
167
|
#
|
164
168
|
# @param [Net::HTTPRequest] request The request object to send
|
169
|
+
# @param [Boolean] follow_redirect whether to follow redirects or not
|
165
170
|
#
|
166
171
|
# @return [Net::HTTPResponse] Response from Jenkins
|
167
172
|
#
|
168
|
-
def make_http_request(
|
173
|
+
def make_http_request(request, follow_redirect = @follow_redirects)
|
174
|
+
request.basic_auth @username, @password if @username
|
175
|
+
|
169
176
|
if @server_url
|
170
177
|
http = Net::HTTP.new(@server_uri.host, @server_uri.port)
|
171
178
|
http.use_ssl = true if @ssl
|
172
179
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @ssl
|
173
|
-
|
180
|
+
response = http.request(request)
|
174
181
|
else
|
175
182
|
Net::HTTP.start(
|
176
183
|
@server_ip, @server_port, @proxy_ip, @proxy_port, :use_ssl => @ssl
|
177
184
|
) do |http|
|
178
|
-
|
185
|
+
response = http.request(request)
|
179
186
|
end
|
180
187
|
end
|
188
|
+
case response
|
189
|
+
when Net::HTTPRedirection then
|
190
|
+
# If we got a redirect request, follow it (if flag set), but don't
|
191
|
+
# go any deeper (only one redirect supported - don't want to follow
|
192
|
+
# our tail)
|
193
|
+
if follow_redirect
|
194
|
+
redir_uri = URI.parse(response['location'])
|
195
|
+
response = make_http_request(
|
196
|
+
Net::HTTP::Get.new(redir_uri.path, false)
|
197
|
+
)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
return response
|
181
201
|
end
|
182
202
|
protected :make_http_request
|
183
203
|
|
@@ -188,7 +208,6 @@ module JenkinsApi
|
|
188
208
|
#
|
189
209
|
def get_root
|
190
210
|
request = Net::HTTP::Get.new("/")
|
191
|
-
request.basic_auth @username, @password
|
192
211
|
make_http_request(request)
|
193
212
|
end
|
194
213
|
|
@@ -214,7 +233,6 @@ module JenkinsApi
|
|
214
233
|
to_get = URI.escape(to_get)
|
215
234
|
request = Net::HTTP::Get.new(to_get)
|
216
235
|
puts "[INFO] GET #{to_get}" if @debug
|
217
|
-
request.basic_auth @username, @password
|
218
236
|
response = make_http_request(request)
|
219
237
|
if raw_response
|
220
238
|
response
|
@@ -230,13 +248,14 @@ module JenkinsApi
|
|
230
248
|
#
|
231
249
|
# @return [String] Response code form Jenkins Response
|
232
250
|
#
|
233
|
-
def api_post_request(url_prefix, form_data =
|
251
|
+
def api_post_request(url_prefix, form_data = {})
|
252
|
+
# Added form_data default {} instead of nil to help with proxies
|
253
|
+
# that barf with empty post
|
234
254
|
url_prefix = URI.escape("#{@jenkins_path}#{url_prefix}")
|
235
255
|
request = Net::HTTP::Post.new("#{url_prefix}")
|
236
|
-
puts "[INFO]
|
237
|
-
request.basic_auth @username, @password
|
256
|
+
puts "[INFO] POST #{url_prefix}" if @debug
|
238
257
|
request.content_type = 'application/json'
|
239
|
-
request.set_form_data(form_data)
|
258
|
+
request.set_form_data(form_data)
|
240
259
|
response = make_http_request(request)
|
241
260
|
handle_exception(response)
|
242
261
|
end
|
@@ -251,7 +270,6 @@ module JenkinsApi
|
|
251
270
|
url_prefix = URI.escape("#{@jenkins_path}#{url_prefix}")
|
252
271
|
request = Net::HTTP::Get.new("#{url_prefix}/config.xml")
|
253
272
|
puts "[INFO] GET #{url_prefix}/config.xml" if @debug
|
254
|
-
request.basic_auth @username, @password
|
255
273
|
response = make_http_request(request)
|
256
274
|
handle_exception(response, "body")
|
257
275
|
end
|
@@ -266,8 +284,7 @@ module JenkinsApi
|
|
266
284
|
def post_config(url_prefix, xml)
|
267
285
|
url_prefix = URI.escape("#{@jenkins_path}#{url_prefix}")
|
268
286
|
request = Net::HTTP::Post.new("#{url_prefix}")
|
269
|
-
puts "[INFO]
|
270
|
-
request.basic_auth @username, @password
|
287
|
+
puts "[INFO] POST #{url_prefix}" if @debug
|
271
288
|
request.body = xml
|
272
289
|
request.content_type = 'application/xml'
|
273
290
|
response = make_http_request(request)
|
@@ -360,7 +377,10 @@ module JenkinsApi
|
|
360
377
|
msg = "HTTP Code: #{response.code}, Response Body: #{response.body}"
|
361
378
|
puts msg if @debug
|
362
379
|
case response.code.to_i
|
363
|
-
|
380
|
+
# As of Jenkins version 1.519, the job builds return a 201 status code
|
381
|
+
# with a Location HTTP header with the pointing the URL of the item in
|
382
|
+
# the queue.
|
383
|
+
when 200, 201, 302
|
364
384
|
if to_send == "body" && send_json
|
365
385
|
return JSON.parse(response.body)
|
366
386
|
elsif to_send == "body"
|
@@ -479,7 +479,10 @@ module JenkinsApi
|
|
479
479
|
"unstable"
|
480
480
|
when /anime/
|
481
481
|
"running"
|
482
|
-
|
482
|
+
# In the recent version of Jenkins (> 1.517), jobs that are not built
|
483
|
+
# yet have a color of "notbuilt" instead of "grey". Include that to the
|
484
|
+
# not_run condition so it is backward compatible.
|
485
|
+
when "grey", "notbuilt"
|
483
486
|
"not_run"
|
484
487
|
when "aborted"
|
485
488
|
"aborted"
|
@@ -549,6 +552,32 @@ module JenkinsApi
|
|
549
552
|
@client.post_config("/job/#{job_name}/config.xml", xml)
|
550
553
|
end
|
551
554
|
|
555
|
+
# Obtain the test results for a specific build of a job
|
556
|
+
#
|
557
|
+
# @param [String] job_name
|
558
|
+
# @param [Number] build_num
|
559
|
+
#
|
560
|
+
def get_test_results(job_name, build_num)
|
561
|
+
build_num = get_current_build_number(job_name) if build_num == 0
|
562
|
+
|
563
|
+
@client.api_get_request("/job/#{job_name}/#{build_num}/testReport")
|
564
|
+
rescue Exceptions::NotFoundException
|
565
|
+
# Not found is acceptable, as not all builds will have test results
|
566
|
+
# and this is what jenkins throws at us in that case
|
567
|
+
nil
|
568
|
+
end
|
569
|
+
|
570
|
+
# Obtain detailed build info for a job
|
571
|
+
#
|
572
|
+
# @param [String] job_name
|
573
|
+
# @param [Number] build_num
|
574
|
+
#
|
575
|
+
def get_build_details(job_name, build_num)
|
576
|
+
build_num = get_current_build_number(job_name) if build_num == 0
|
577
|
+
|
578
|
+
@client.api_get_request("/job/#{job_name}/#{build_num}/")
|
579
|
+
end
|
580
|
+
|
552
581
|
# Change the description of a specific job
|
553
582
|
#
|
554
583
|
# @param [String] job_name
|
@@ -165,7 +165,7 @@ module JenkinsApi
|
|
165
165
|
# @param [String] filter a regex to filter view names
|
166
166
|
# @param [Bool] ignorecase whether to be case sensitive or not
|
167
167
|
#
|
168
|
-
def list(filter =
|
168
|
+
def list(filter = "", ignorecase = true)
|
169
169
|
view_names = []
|
170
170
|
response_json = @client.api_get_request("/")
|
171
171
|
response_json["views"].each { |view|
|
data/spec/func_tests/job_spec.rb
CHANGED
@@ -367,7 +367,9 @@ describe JenkinsApi::Client::Job do
|
|
367
367
|
@job_name
|
368
368
|
).should_not == "running"
|
369
369
|
response = @client.job.build(@job_name)
|
370
|
-
|
370
|
+
# As of Jenkins version 1.519 the job build responds with a 201
|
371
|
+
# status code.
|
372
|
+
[201, 302].should include(response.to_i)
|
371
373
|
# Sleep for 6 seconds so we don't hit the Jenkins quiet period (5
|
372
374
|
# seconds)
|
373
375
|
sleep 6
|
@@ -25,6 +25,17 @@ describe JenkinsApi::Client do
|
|
25
25
|
).not_to raise_error
|
26
26
|
end
|
27
27
|
|
28
|
+
it "initialize without exception if username/password not specified" do
|
29
|
+
expect(
|
30
|
+
lambda do
|
31
|
+
JenkinsApi::Client.new({
|
32
|
+
:server_ip => '127.0.0.1',
|
33
|
+
:server_port => 8080
|
34
|
+
})
|
35
|
+
end
|
36
|
+
).not_to raise_error
|
37
|
+
end
|
38
|
+
|
28
39
|
it "initializes with server_url without exception" do
|
29
40
|
expect(
|
30
41
|
lambda do
|
@@ -51,6 +62,20 @@ describe JenkinsApi::Client do
|
|
51
62
|
end
|
52
63
|
).not_to raise_error
|
53
64
|
end
|
65
|
+
|
66
|
+
it "errors on bad proxy args" do
|
67
|
+
expect(
|
68
|
+
lambda do
|
69
|
+
JenkinsApi::Client.new(
|
70
|
+
:server_ip => '127.0.0.1',
|
71
|
+
:server_port => 8080,
|
72
|
+
:username => 'username',
|
73
|
+
:password => 'password',
|
74
|
+
:proxy_ip => '127.0.0.1'
|
75
|
+
)
|
76
|
+
end
|
77
|
+
).to raise_error
|
78
|
+
end
|
54
79
|
end
|
55
80
|
|
56
81
|
describe "#SubClassAccessorMethods" do
|
@@ -241,19 +266,6 @@ describe JenkinsApi::Client do
|
|
241
266
|
).to raise_error
|
242
267
|
end
|
243
268
|
|
244
|
-
it "Should fail if username is missing" do
|
245
|
-
expect(
|
246
|
-
lambda do
|
247
|
-
JenkinsApi::Client.new({
|
248
|
-
:server_ip => '127.0.0.1',
|
249
|
-
:server_port => 8080,
|
250
|
-
:bogus => 'username',
|
251
|
-
:password => 'password'
|
252
|
-
})
|
253
|
-
end
|
254
|
-
).to raise_error
|
255
|
-
end
|
256
|
-
|
257
269
|
it "Should fail if password is missing" do
|
258
270
|
expect(
|
259
271
|
lambda do
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
2
|
+
<hudson>
|
3
|
+
<disabledAdministrativeMonitors/>
|
4
|
+
<version>1.517</version>
|
5
|
+
<numExecutors>10</numExecutors>
|
6
|
+
<mode>NORMAL</mode>
|
7
|
+
<useSecurity>true</useSecurity>
|
8
|
+
<authorizationStrategy class="hudson.security.GlobalMatrixAuthorizationStrategy">
|
9
|
+
<permission>hudson.model.Computer.Configure:testuser</permission>
|
10
|
+
<permission>hudson.model.Computer.Connect:testuser</permission>
|
11
|
+
<permission>hudson.model.Computer.Create:testuser</permission>
|
12
|
+
<permission>hudson.model.Computer.Delete:testuser</permission>
|
13
|
+
<permission>hudson.model.Computer.Disconnect:testuser</permission>
|
14
|
+
<permission>hudson.model.Hudson.Administer:testuser</permission>
|
15
|
+
<permission>hudson.model.Hudson.ConfigureUpdateCenter:testuser</permission>
|
16
|
+
<permission>hudson.model.Hudson.Read:testuser</permission>
|
17
|
+
<permission>hudson.model.Hudson.RunScripts:testuser</permission>
|
18
|
+
<permission>hudson.model.Hudson.UploadPlugins:testuser</permission>
|
19
|
+
<permission>hudson.model.Item.Build:testuser</permission>
|
20
|
+
<permission>hudson.model.Item.Cancel:testuser</permission>
|
21
|
+
<permission>hudson.model.Item.Configure:testuser</permission>
|
22
|
+
<permission>hudson.model.Item.Create:testuser</permission>
|
23
|
+
<permission>hudson.model.Item.Delete:testuser</permission>
|
24
|
+
<permission>hudson.model.Item.Discover:testuser</permission>
|
25
|
+
<permission>hudson.model.Item.Read:testuser</permission>
|
26
|
+
<permission>hudson.model.Item.Workspace:testuser</permission>
|
27
|
+
<permission>hudson.model.View.Configure:testuser</permission>
|
28
|
+
<permission>hudson.model.View.Create:testuser</permission>
|
29
|
+
<permission>hudson.model.View.Delete:testuser</permission>
|
30
|
+
<permission>hudson.model.View.Read:testuser</permission>
|
31
|
+
</authorizationStrategy>
|
32
|
+
<securityRealm class="hudson.security.HudsonPrivateSecurityRealm">
|
33
|
+
<disableSignup>false</disableSignup>
|
34
|
+
<enableCaptcha>false</enableCaptcha>
|
35
|
+
</securityRealm>
|
36
|
+
<projectNamingStrategy class="jenkins.model.ProjectNamingStrategy$DefaultProjectNamingStrategy"/>
|
37
|
+
<workspaceDir>${JENKINS_HOME}/workspace/${ITEM_FULLNAME}</workspaceDir>
|
38
|
+
<buildsDir>${ITEM_ROOTDIR}/builds</buildsDir>
|
39
|
+
<markupFormatter class="hudson.markup.RawHtmlMarkupFormatter">
|
40
|
+
<disableSyntaxHighlighting>false</disableSyntaxHighlighting>
|
41
|
+
</markupFormatter>
|
42
|
+
<jdks/>
|
43
|
+
<viewsTabBar class="hudson.views.DefaultViewsTabBar"/>
|
44
|
+
<myViewsTabBar class="hudson.views.DefaultMyViewsTabBar"/>
|
45
|
+
<clouds/>
|
46
|
+
<slaves/>
|
47
|
+
<quietPeriod>5</quietPeriod>
|
48
|
+
<scmCheckoutRetryCount>0</scmCheckoutRetryCount>
|
49
|
+
<views>
|
50
|
+
<hudson.model.AllView>
|
51
|
+
<owner class="hudson" reference="../../.."/>
|
52
|
+
<name>All</name>
|
53
|
+
<filterExecutors>false</filterExecutors>
|
54
|
+
<filterQueue>false</filterQueue>
|
55
|
+
<properties class="hudson.model.View$PropertyList"/>
|
56
|
+
</hudson.model.AllView>
|
57
|
+
</views>
|
58
|
+
<primaryView>All</primaryView>
|
59
|
+
<slaveAgentPort>0</slaveAgentPort>
|
60
|
+
<label></label>
|
61
|
+
<nodeProperties/>
|
62
|
+
<globalNodeProperties/>
|
63
|
+
</hudson>
|
data/travis/setup.sh
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# Install Jenkins
|
4
|
+
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
|
5
|
+
sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list'
|
6
|
+
sudo apt-get update -qq
|
7
|
+
sudo apt-get install -qq jenkins
|
8
|
+
|
9
|
+
# Configure Jenkins
|
10
|
+
sudo service jenkins stop
|
11
|
+
sudo cp -f travis/jenkins_config.xml /var/lib/jenkins/config.xml
|
12
|
+
sudo mkdir -p /var/lib/jenkins/users/testuser
|
13
|
+
sudo cp -f travis/user_config.xml /var/lib/jenkins/users/testuser/config.xml
|
14
|
+
sudo service jenkins start
|
15
|
+
# Jenkins takes a bit to get dressed up and become ready, so be patient...
|
16
|
+
sleep 60
|
17
|
+
cat /var/log/jenkins/jenkins.log
|
18
|
+
echo `sudo service jenkins status`
|
19
|
+
|
20
|
+
# Create the credentials file used by functional tests
|
21
|
+
sudo mkdir ~/.jenkins_api_client
|
22
|
+
sudo cp -f travis/spec.yml ~/.jenkins_api_client/spec.yml
|
data/travis/spec.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
2
|
+
<user>
|
3
|
+
<fullName>Test User</fullName>
|
4
|
+
<properties>
|
5
|
+
<jenkins.security.ApiTokenProperty>
|
6
|
+
<apiToken></apiToken>
|
7
|
+
</jenkins.security.ApiTokenProperty>
|
8
|
+
<hudson.model.MyViewsProperty>
|
9
|
+
<views>
|
10
|
+
<hudson.model.AllView>
|
11
|
+
<owner class="hudson.model.MyViewsProperty" reference="../../.."/>
|
12
|
+
<name>All</name>
|
13
|
+
<filterExecutors>false</filterExecutors>
|
14
|
+
<filterQueue>false</filterQueue>
|
15
|
+
<properties class="hudson.model.View$PropertyList"/>
|
16
|
+
</hudson.model.AllView>
|
17
|
+
</views>
|
18
|
+
</hudson.model.MyViewsProperty>
|
19
|
+
<hudson.search.UserSearchProperty>
|
20
|
+
<insensitiveSearch>false</insensitiveSearch>
|
21
|
+
</hudson.search.UserSearchProperty>
|
22
|
+
<hudson.security.HudsonPrivateSecurityRealm_-Details>
|
23
|
+
<passwordHash>#jbcrypt:$2a$10$L051Dt2g4qlq0ABI8PtGIurtvuKVU7HcXAgwUAvy8vMA/CPXDLEdm</passwordHash>
|
24
|
+
</hudson.security.HudsonPrivateSecurityRealm_-Details>
|
25
|
+
<hudson.tasks.Mailer_-UserProperty>
|
26
|
+
<emailAddress>testuser@testdomain.com</emailAddress>
|
27
|
+
</hudson.tasks.Mailer_-UserProperty>
|
28
|
+
</properties>
|
29
|
+
</user>
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 12
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.12.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Kannan Manickam
|
@@ -14,18 +14,20 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2013-06-
|
17
|
+
date: 2013-06-19 00:00:00 -07:00
|
18
18
|
default_executable: jenkinscli
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
type: :runtime
|
22
22
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
segments:
|
27
|
+
- 1
|
28
|
+
- 5
|
27
29
|
- 0
|
28
|
-
version:
|
30
|
+
version: 1.5.0
|
29
31
|
name: nokogiri
|
30
32
|
requirement: *id001
|
31
33
|
prerelease: false
|
@@ -189,6 +191,10 @@ files:
|
|
189
191
|
- spec/unit_tests/spec_helper.rb
|
190
192
|
- spec/unit_tests/system_spec.rb
|
191
193
|
- spec/unit_tests/view_spec.rb
|
194
|
+
- travis/jenkins_config.xml
|
195
|
+
- travis/setup.sh
|
196
|
+
- travis/spec.yml
|
197
|
+
- travis/user_config.xml
|
192
198
|
has_rdoc: true
|
193
199
|
homepage: https://github.com/arangamani/jenkins_api_client
|
194
200
|
licenses: []
|