improved_jenkins_client 1.6.0 → 1.6.5
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: 6d924687d191c069d05698fc954924efa40f1024ab280be5d7d13f434c20b680
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 760ca0221281fec74064f4f151927ff765dc2f0024c155ed0bdf154f02346f9a
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 4f46f6c49204c1ac5562d2dad223eec0411e622404f0fe6db4824a792367809b1237b202db9d6951037d4271f4434adf8c90e13dcd0d742bf428c09fc4c70f6d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: c54d3c43bc7ddc242bf63081f4bde37e7b3e9700f73badbcac2681e2dbbd89e95d21eb5192b80a46aca1ad833d5bd1875c02dc6bfa12920bde4877c7b4d3d81e
         
     | 
| 
         @@ -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"
         
     | 
| 
         @@ -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,8 +807,11 @@ 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)
         
     | 
| 
      
 810 
     | 
    
         
            +
                def handle_exception(response, to_send = "code", send_json = false, full_url: nil)
         
     | 
| 
       801 
811 
     | 
    
         
             
                  msg = "HTTP Code: #{response.code}, Response Body: #{response.body}"
         
     | 
| 
      
 812 
     | 
    
         
            +
                  unless full_url.nil?
         
     | 
| 
      
 813 
     | 
    
         
            +
                    msg += " URL: #{full_url}"
         
     | 
| 
      
 814 
     | 
    
         
            +
                  end
         
     | 
| 
       802 
815 
     | 
    
         
             
                  @logger.debug msg
         
     | 
| 
       803 
816 
     | 
    
         
             
                  case response.code.to_i
         
     | 
| 
       804 
817 
     | 
    
         
             
                  # As of Jenkins version 1.519, the job builds return a 201 status code
         
     | 
| 
         @@ -723,14 +723,73 @@ 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
         
     | 
| 
       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
         
     | 
| 
         @@ -1134,13 +1193,14 @@ module JenkinsApi 
     | 
|
| 
       1134 
1193 
     | 
    
         
             
                  #
         
     | 
| 
       1135 
1194 
     | 
    
         
             
                  # @param [String] job_name
         
     | 
| 
       1136 
1195 
     | 
    
         
             
                  # @param [Number] build_num
         
     | 
| 
      
 1196 
     | 
    
         
            +
                  # @param [String] tree
         
     | 
| 
       1137 
1197 
     | 
    
         
             
                  #
         
     | 
| 
       1138 
     | 
    
         
            -
                  def get_build_details(job_name, build_num)
         
     | 
| 
      
 1198 
     | 
    
         
            +
                  def get_build_details(job_name, build_num, tree: nil)
         
     | 
| 
       1139 
1199 
     | 
    
         
             
                    build_num = get_current_build_number(job_name) if build_num == 0
         
     | 
| 
       1140 
     | 
    
         
            -
                     
     | 
| 
       1141 
     | 
    
         
            -
             
     | 
| 
      
 1200 
     | 
    
         
            +
                    log_msg = "Obtaining the build details of '#{job_name}' Build ##{build_num}"
         
     | 
| 
      
 1201 
     | 
    
         
            +
                    log_msg += " (with tree=...)" unless tree.nil?
         
     | 
| 
       1142 
1202 
     | 
    
         | 
| 
       1143 
     | 
    
         
            -
                    @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))
         
     | 
| 
       1144 
1204 
     | 
    
         
             
                  end
         
     | 
| 
       1145 
1205 
     | 
    
         | 
| 
       1146 
1206 
     | 
    
         
             
                  # Change the description of a specific 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.5
         
     | 
| 
       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: {}
         
     | 
| 
         @@ -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
         
     |