improved_jenkins_client 1.6.3 → 1.6.7
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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0b836a0050b0fac502e19aaa527a175e98cd33f92f3c1b450f9616136140c08
|
4
|
+
data.tar.gz: 4b49c8cd16ba499e768fbdea346ff08e607597012de67c226cc3b515e4bfa729
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e4f9929f81880760be739a58ddda8475d70caa1a330c896aedd5cdef80ce53e464c0556843fa33fc7d4f1d9e353bf05d18e021cef68c1032ed99577bbe60e69
|
7
|
+
data.tar.gz: 29a6315717c1e4f57d6eaae520a37a6b804aea07c990cc7751030113615e409800a0a672b790024bcb0bf2dfac33bfb9c8739b17a1e6e2051e0b9d0d6627d26c
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r{lib/|bin/|java_deps/|gemspec}) }
|
21
21
|
s.require_paths = ['lib']
|
22
22
|
s.homepage = 'https://github.com/yugabyte-db/improved_jenkins_client'
|
23
|
-
s.required_ruby_version = ::Gem::Requirement.new('
|
23
|
+
s.required_ruby_version = ::Gem::Requirement.new('>= 2.1')
|
24
24
|
s.rubygems_version = "2.4.5.1"
|
25
25
|
s.summary = "Improved Jenkins JSON API Client"
|
26
26
|
s.licenses = ["MIT"]
|
@@ -257,6 +257,13 @@ module JenkinsApi
|
|
257
257
|
stuck
|
258
258
|
end
|
259
259
|
|
260
|
+
# Cancel the given task
|
261
|
+
#
|
262
|
+
# @param [String] task_id the task id
|
263
|
+
def cancel_item(task_id)
|
264
|
+
@client.api_post_request("/queue/cancelItem?id=#{task_id}")
|
265
|
+
end
|
266
|
+
|
260
267
|
end
|
261
268
|
end
|
262
269
|
end
|
@@ -72,7 +72,8 @@ module JenkinsApi
|
|
72
72
|
"ca_file",
|
73
73
|
"follow_redirects",
|
74
74
|
"identity_file",
|
75
|
-
"cookies"
|
75
|
+
"cookies",
|
76
|
+
"pretty_json_responses"
|
76
77
|
].freeze
|
77
78
|
|
78
79
|
# Initialize a Client object with Jenkins CI server credentials
|
@@ -106,6 +107,7 @@ module JenkinsApi
|
|
106
107
|
# @option args [Fixnum] :log_level (Logger::INFO) The level for messages to be logged. Should be one of:
|
107
108
|
# Logger::DEBUG (0), Logger::INFO (1), Logger::WARN (2), Logger::ERROR (2), Logger::FATAL (3)
|
108
109
|
# @option args [String] :cookies Cookies to be sent with all requests in the format: name=value; name2=value2
|
110
|
+
# @option args [Boolean] :pretty_json_responses Whether to append pretty=true to most JSON GET requests.
|
109
111
|
#
|
110
112
|
# @return [JenkinsApi::Client] a client object to Jenkins API
|
111
113
|
#
|
@@ -415,18 +417,26 @@ module JenkinsApi
|
|
415
417
|
raw_response = false)
|
416
418
|
url_prefix = "#{@jenkins_path}#{url_prefix}"
|
417
419
|
to_get = ""
|
420
|
+
|
421
|
+
|
418
422
|
if tree
|
419
423
|
to_get = "#{url_prefix}#{url_suffix}?#{tree}"
|
424
|
+
query_param_separator = "&"
|
420
425
|
else
|
421
426
|
to_get = "#{url_prefix}#{url_suffix}"
|
427
|
+
query_param_separator = "?"
|
428
|
+
end
|
429
|
+
if @pretty_json_responses && url_suffix == "/api/json"
|
430
|
+
to_get += query_param_separator
|
431
|
+
to_get += "pretty=true"
|
422
432
|
end
|
423
433
|
request = Net::HTTP::Get.new(to_get)
|
424
434
|
@logger.debug "GET #{to_get}"
|
425
435
|
response = make_http_request(request)
|
426
436
|
if raw_response
|
427
|
-
handle_exception(response, "raw")
|
437
|
+
handle_exception(response, "raw", full_url: to_get)
|
428
438
|
else
|
429
|
-
handle_exception(response, "body", url_suffix =~ /json
|
439
|
+
handle_exception(response, "body", url_suffix =~ /json/, full_url: to_get)
|
430
440
|
end
|
431
441
|
end
|
432
442
|
|
@@ -797,14 +807,25 @@ module JenkinsApi
|
|
797
807
|
# @raise [Exceptions::ApiException] Any other exception returned from
|
798
808
|
# Jenkins that are not categorized in the API Client.
|
799
809
|
#
|
800
|
-
def handle_exception(response, to_send = "code", send_json = false)
|
801
|
-
msg = "HTTP Code: #{response.code}
|
802
|
-
|
803
|
-
|
810
|
+
def handle_exception(response, to_send = "code", send_json = false, full_url: nil)
|
811
|
+
msg = "HTTP Code: #{response.code} "
|
812
|
+
|
813
|
+
msg += ", URL: #{full_url}" unless full_url.nil?
|
814
|
+
|
815
|
+
if @logger.level <= Logger::DEBUG
|
816
|
+
@logger.debug "#{msg}; Response Body: #{response.body}"
|
817
|
+
end
|
818
|
+
response_code = response.code.to_i
|
819
|
+
if response_code >= 400
|
820
|
+
@logger.warn msg
|
821
|
+
end
|
822
|
+
|
823
|
+
case response_code
|
804
824
|
# As of Jenkins version 1.519, the job builds return a 201 status code
|
805
825
|
# with a Location HTTP header with the pointing the URL of the item in
|
806
826
|
# the queue.
|
807
|
-
|
827
|
+
#
|
828
|
+
when 200, 201, 204, 302
|
808
829
|
if to_send == "body" && send_json
|
809
830
|
return JSON.parse(response.body)
|
810
831
|
elsif to_send == "body"
|
@@ -817,7 +838,7 @@ module JenkinsApi
|
|
817
838
|
when 400
|
818
839
|
matched = response.body.match(/<p>(.*)<\/p>/)
|
819
840
|
api_message = matched[1] unless matched.nil?
|
820
|
-
@logger.
|
841
|
+
@logger.warn "API message: #{api_message}"
|
821
842
|
case api_message
|
822
843
|
when /A job already exists with the name/
|
823
844
|
raise Exceptions::JobAlreadyExists.new(@logger, api_message)
|
@@ -839,7 +860,7 @@ module JenkinsApi
|
|
839
860
|
when 500
|
840
861
|
matched = response.body.match(/Exception: (.*)<br>/)
|
841
862
|
api_message = matched[1] unless matched.nil?
|
842
|
-
@logger.
|
863
|
+
@logger.warn "API message: #{api_message}"
|
843
864
|
raise Exceptions::InternalServerError.new(@logger, api_message)
|
844
865
|
when 503
|
845
866
|
raise Exceptions::ServiceUnavailable.new @logger
|
@@ -723,7 +723,7 @@ module JenkinsApi
|
|
723
723
|
# @param [String] job_name
|
724
724
|
#
|
725
725
|
def get_builds(job_name, options = {})
|
726
|
-
@logger.info "Obtaining the
|
726
|
+
@logger.info "Obtaining the builds of job '#{job_name}'"
|
727
727
|
url = "/job/#{path_encode job_name}"
|
728
728
|
|
729
729
|
tree = options[:tree]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: improved_jenkins_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kannan Manickam (the original jenkins_api_client gem)
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-11-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -156,7 +156,7 @@ require_paths:
|
|
156
156
|
- lib
|
157
157
|
required_ruby_version: !ruby/object:Gem::Requirement
|
158
158
|
requirements:
|
159
|
-
- - "
|
159
|
+
- - ">="
|
160
160
|
- !ruby/object:Gem::Version
|
161
161
|
version: '2.1'
|
162
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -165,7 +165,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
requirements: []
|
168
|
-
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 2.7.6.3
|
169
170
|
signing_key:
|
170
171
|
specification_version: 4
|
171
172
|
summary: Improved Jenkins JSON API Client
|