From fbb160edab68e37e97e87aac204c36a257c188b5 Mon Sep 17 00:00:00 2001 From: Jeffrey Harvey-Smith Date: Mon, 27 Nov 2017 01:41:10 -0800 Subject: [PATCH] Try to fix some test failures. --- lib/jenkins_api_client/job.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/jenkins_api_client/job.rb b/lib/jenkins_api_client/job.rb index e83cde8f..9c124cee 100644 --- a/lib/jenkins_api_client/job.rb +++ b/lib/jenkins_api_client/job.rb @@ -1659,8 +1659,8 @@ def artifact_exists?(job_name, build_number = 0) # def find_artifacts(job_name, build_number = nil) response_json = get_build_details(job_name, build_number) - relative_build_path = artifact_path(build_details: response_json).map do |p| - URI.escape("#{response_json['url']}/artifact/#{relative_build_path}") + artifact_path(build_details: response_json).map do |p| + URI.escape("#{response_json['url']}artifact/#{relative_build_path}") end end @@ -1923,12 +1923,16 @@ def artifact_path(params) build_details = get_build_details(job_name, build_number) if build_details.nil? artifacts = build_details['artifacts'] + artifact_paths = [] if artifacts && artifacts.any? - return artifacts.find_all{ |a| a.key?('relativePath') } - else + artifact_paths = artifacts.find_all{ |a| a.key?('relativePath') } + end + + if artifact_paths.empty? raise "No artifacts found." end + artifact_paths end end end