improved_jenkins_client 1.6.2 → 1.6.6
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: f381907a06146eab9fc814b98a7233a8981a570e2f5f812936f22d5d745844f5
|
4
|
+
data.tar.gz: 8f2011c9223b397e8d3045d259f715f3e346fa4bad1f24d778cb743699781a92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9df1bcd1a5b4e9db2ac14074f20d36082d60ce9f7f3132b896df69ca79a8fce2fe3649d0bcc62284480c754ad9db72135fb88523b29f5be1678b43eb14a4527
|
7
|
+
data.tar.gz: 647de6de4983fc9138dcbe815f37d2c8f7dcc0cfa879d16edf3ee6c0f1296d4dbf0621a9d75b18693674e7571fe238ee170f40ba3074813479ec2cf6decc30bd
|
@@ -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,10 +807,20 @@ 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.
|
@@ -817,7 +837,7 @@ module JenkinsApi
|
|
817
837
|
when 400
|
818
838
|
matched = response.body.match(/<p>(.*)<\/p>/)
|
819
839
|
api_message = matched[1] unless matched.nil?
|
820
|
-
@logger.
|
840
|
+
@logger.warn "API message: #{api_message}"
|
821
841
|
case api_message
|
822
842
|
when /A job already exists with the name/
|
823
843
|
raise Exceptions::JobAlreadyExists.new(@logger, api_message)
|
@@ -839,7 +859,7 @@ module JenkinsApi
|
|
839
859
|
when 500
|
840
860
|
matched = response.body.match(/Exception: (.*)<br>/)
|
841
861
|
api_message = matched[1] unless matched.nil?
|
842
|
-
@logger.
|
862
|
+
@logger.warn "API message: #{api_message}"
|
843
863
|
raise Exceptions::InternalServerError.new(@logger, api_message)
|
844
864
|
when 503
|
845
865
|
raise Exceptions::ServiceUnavailable.new @logger
|
@@ -723,10 +723,10 @@ 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
|
-
tree = options[:tree]
|
729
|
+
tree = options[:tree]
|
730
730
|
response_json = @client.api_get_request url, tree_string(tree)
|
731
731
|
response_json["builds"]
|
732
732
|
end
|
@@ -1193,13 +1193,14 @@ module JenkinsApi
|
|
1193
1193
|
#
|
1194
1194
|
# @param [String] job_name
|
1195
1195
|
# @param [Number] build_num
|
1196
|
+
# @param [String] tree
|
1196
1197
|
#
|
1197
|
-
def get_build_details(job_name, build_num)
|
1198
|
+
def get_build_details(job_name, build_num, tree: nil)
|
1198
1199
|
build_num = get_current_build_number(job_name) if build_num == 0
|
1199
|
-
|
1200
|
-
|
1200
|
+
log_msg = "Obtaining the build details of '#{job_name}' Build ##{build_num}"
|
1201
|
+
log_msg += " (with tree=...)" unless tree.nil?
|
1201
1202
|
|
1202
|
-
@client.api_get_request("/job/#{path_encode job_name}/#{build_num}/")
|
1203
|
+
@client.api_get_request("/job/#{path_encode job_name}/#{build_num}/", tree_string(tree))
|
1203
1204
|
end
|
1204
1205
|
|
1205
1206
|
# Change the description of a specific job
|
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.6
|
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-10-
|
12
|
+
date: 2021-10-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
@@ -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
|