Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New endpoints + bug fixes #310

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/jenkins_api_client/build_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ def get_age(task_name)
age
end

# Obtains ALL queue items with detail Hash from the API response
#
# @param [String] task_name Name of the task/job
#
# @return [Hash] Queue details of the specified task/job
#
def get_all_with_details(task_name)
@logger.info "Obtaining all queue items with details of task '#{task_name}' from the" +
" build queue"
response_json = @client.api_get_request("/queue/api/json")
details = []
response_json["items"].each do |item|
details << item if item["task"]["name"] == task_name
end
details
end

# Obtains the detail Hash from the API response
#
# @param [String] task_name Name of the task/job
Expand Down
11 changes: 9 additions & 2 deletions lib/jenkins_api_client/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class Client
def initialize(args)
args = symbolize_keys(args)
args.each do |key, value|
if value && VALID_PARAMS.include?(key.to_s)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did this change ?

if VALID_PARAMS.include?(key.to_s)
instance_variable_set("@#{key}", value)
end
end if args.is_a? Hash
Expand Down Expand Up @@ -363,7 +363,14 @@ def make_http_request(request, follow_redirect = @follow_redirects)
http.use_ssl = true

http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.ca_file = @ca_file if @ca_file

if @ca_file
http.ca_file = @ca_file
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use 2-space indent

else
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
else
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
Comment on lines +370 to +373
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like an unsafe default

end
http.open_timeout = @http_open_timeout
http.read_timeout = @http_read_timeout
Expand Down
21 changes: 21 additions & 0 deletions lib/jenkins_api_client/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,27 @@ def get_builds(job_name, options = {})
response_json["builds"]
end

# Obtain build details of a single build
#
# @param [String] job_name
#
# @param [Number] build_number
#
# @return [Hash] Build details of the specified build
#
def get_build_details(job_name, build_number = nil, options = {})
if build_number.nil?
build_number = get_current_build_number(job_name)
end

@logger.info "Obtaining the build details of '#{job_name}' / build ##{build_number}"
url = "/job/#{path_encode job_name}/#{build_number}/api/json"

tree = options[:tree] || nil
response_json = @client.api_get_request url, tree_string(tree)
response_json["builds"]
end

# This method maps the color to status of a job
#
# @param [String] color color given by the API for a job
Expand Down