Sha256: 6a5dd7ee6995dfb99fafd1bdb88ff62b32efba3ccf7b50b91d368cb72b1acd2c
Contents?: true
Size: 1.23 KB
Versions: 3
Compression:
Stored size: 1.23 KB
Contents
require 'json' require 'cgi' require 'bukin/file_match' module Bukin # Api for downloading from jenkins class Jenkins attr_reader :url VERSION = 'lastSuccessfulBuild' GOOD_VERSIONS = "'build-125'" def initialize(url) @url = url end def find(data) name = data[:name] version = data[:version] match = data[:file] ? FileMatch.new(data[:file]) : FileMatch.any if version.nil? || version == VERSION build = VERSION elsif correct_version_format?(version) build = version[/^build-([0-9]+)$/, 1] else raise VersionError.new(name, version, GOOD_VERSIONS) end base_path = "#{@url}/job/#{CGI.escape(name)}/#{CGI.escape(build)}" info = Bukin.try_get_json("#{base_path}/api/json") raise NoDownloadError.new(name, version) unless info download_info = info['artifacts'].find{|file| match =~ file['fileName']} raise NoDownloadError.new(name, version) unless download_info download = "#{base_path}/artifact/#{download_info['relativePath']}" return "build-#{info['number']}", download end private def correct_version_format?(version) version == VERSION || /^build-[0-9]+$/.match(version) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bukin-0.9.0 | lib/bukin/jenkins.rb |
bukin-0.8.0 | lib/bukin/jenkins.rb |
bukin-0.7.0 | lib/bukin/jenkins.rb |