improved_jenkins_client 1.6.0 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/improved_jenkins_client.gemspec +3 -2
- data/lib/improved_jenkins_client/job.rb +59 -0
- data/lib/improved_jenkins_client/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26e682d2f9c008a0943a3ff4d76fdc5a9ea614135eef5ed6f8dfc20c692c1c3d
|
4
|
+
data.tar.gz: 4ee3bc91c1cc3e7c86601012de333e79fde95b73e4b828a7c2e899dd28abd3c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c2c4e95a00b51edd873288112253bcba265475e7dcb50466d0f6d5629850adefb1c9b9ce983cbb4f2ad3b5160a7f1be22827fcf12b4fccb105e060bdd0e3651
|
7
|
+
data.tar.gz: 9053180465db13e212f82b6889a0c9012f52f28dba300b7eb06eae362728120ffd5e43251bd5909bc0633664e7a34286c69b7d88264a3f75807fab9a1e2dc33f
|
@@ -8,7 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
|
9
9
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
10
10
|
s.require_paths = ["lib"]
|
11
|
-
s.authors = ["Kannan Manickam
|
11
|
+
s.authors = ["Kannan Manickam (the original jenkins_api_client gem)",
|
12
|
+
"Yugabyte Engineering Team (improvements)"]
|
12
13
|
s.description =
|
13
14
|
"\nThis is a simple and easy-to-use Jenkins Api client with features focused on" +
|
14
15
|
"\nautomating Job configuration programaticaly. Based on the improved_jenkins_client with" +
|
@@ -18,7 +19,7 @@ Gem::Specification.new do |s|
|
|
18
19
|
s.executables = ['jenkinscli']
|
19
20
|
s.files = `git ls-files -z`.split("\x0").select { |f| f.match(%r{lib/|bin/|java_deps/|gemspec}) }
|
20
21
|
s.require_paths = ['lib']
|
21
|
-
s.homepage = 'https://github.com/yugabyte-db/
|
22
|
+
s.homepage = 'https://github.com/yugabyte-db/improved_jenkins_client'
|
22
23
|
s.required_ruby_version = ::Gem::Requirement.new('~> 2.1')
|
23
24
|
s.rubygems_version = "2.4.5.1"
|
24
25
|
s.summary = "Improved Jenkins JSON API Client"
|
@@ -731,6 +731,65 @@ module JenkinsApi
|
|
731
731
|
response_json["builds"]
|
732
732
|
end
|
733
733
|
|
734
|
+
# Yields all builds using the allBuilds API endpoint.
|
735
|
+
#
|
736
|
+
# @param job_name [String] the job to retrieve builds for
|
737
|
+
# @param fields [Array] the fields to retrieve from each build. ['*'] by default, meaning all
|
738
|
+
# fields
|
739
|
+
# @param limit [Integer] the maximum total number of builds to retrieve
|
740
|
+
# @param page_size [Integer] the number of builds to retrieve at once
|
741
|
+
#
|
742
|
+
def each_build(
|
743
|
+
job_name,
|
744
|
+
fields: ['*'],
|
745
|
+
start_index: 0,
|
746
|
+
limit: nil,
|
747
|
+
page_size: 100)
|
748
|
+
unless page_size.is_a?(Integer) && page_size >= 1
|
749
|
+
raise "Invalid page size: #{page_size} (#{page_size.class}) -- must be at least one"
|
750
|
+
end
|
751
|
+
unless start_index.is_a?(Integer) && start_index >= 0
|
752
|
+
raise "Invalid start index: #{start_index} (#{start_index.class}), must be a " +
|
753
|
+
"nonnegative integer"
|
754
|
+
end
|
755
|
+
unless limit.nil? || limit.is_a?(Integer) && limit >= 0
|
756
|
+
raise "Invalid limit: #{limit} (#{limit.class}) -- must be nil or a non-negative integer"
|
757
|
+
end
|
758
|
+
unless fields.is_a?(Array) && fields.size >= 1
|
759
|
+
raise "Invalid array of fields to retrieve: #{fields} (#{fields.class}), must have at " +
|
760
|
+
"least one element"
|
761
|
+
end
|
762
|
+
|
763
|
+
start_index = 0
|
764
|
+
url = "/job/#{path_encode job_name}"
|
765
|
+
fields_str = fields.join(',')
|
766
|
+
while limit.nil? || start_index < limit do
|
767
|
+
@logger.info(
|
768
|
+
"Obtaining the build details of '#{job_name}' (fields: #{fields}) starting at " +
|
769
|
+
"index #{start_index} with page size #{page_size}")
|
770
|
+
|
771
|
+
end_index = start_index + page_size
|
772
|
+
end_index = limit if !limit.nil? && end_index > limit
|
773
|
+
|
774
|
+
break if start_index >= end_index
|
775
|
+
|
776
|
+
tree = "allBuilds[#{fields_str}]{#{start_index},#{end_index}}"
|
777
|
+
response_json = @client.api_get_request(url, tree_string(tree))
|
778
|
+
build_range = response_json["allBuilds"]
|
779
|
+
|
780
|
+
break if build_range.size == 0 # End of results.
|
781
|
+
|
782
|
+
build_range.each do |result|
|
783
|
+
yield result
|
784
|
+
end
|
785
|
+
|
786
|
+
# We got some results but less than what we asked for. This must be the last page.
|
787
|
+
break if build_range.size < end_index - start_index
|
788
|
+
|
789
|
+
start_index += page_size
|
790
|
+
end
|
791
|
+
end
|
792
|
+
|
734
793
|
# This method maps the color to status of a job
|
735
794
|
#
|
736
795
|
# @param [String] color color given by the API for a job
|
metadata
CHANGED
@@ -1,11 +1,11 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Kannan Manickam
|
8
|
-
- Yugabyte
|
7
|
+
- Kannan Manickam (the original jenkins_api_client gem)
|
8
|
+
- Yugabyte Engineering Team (improvements)
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
@@ -146,7 +146,7 @@ files:
|
|
146
146
|
- lib/improved_jenkins_client/user.rb
|
147
147
|
- lib/improved_jenkins_client/version.rb
|
148
148
|
- lib/improved_jenkins_client/view.rb
|
149
|
-
homepage: https://github.com/yugabyte-db/
|
149
|
+
homepage: https://github.com/yugabyte-db/improved_jenkins_client
|
150
150
|
licenses:
|
151
151
|
- MIT
|
152
152
|
metadata: {}
|