Class: Bukin::Jenkins
- Inherits:
-
Object
- Object
- Bukin::Jenkins
- Defined in:
- lib/bukin/jenkins.rb
Overview
Api for downloading from jenkins
Constant Summary collapse
- VERSION =
'lastSuccessfulBuild'- GOOD_VERSIONS =
"'build-125'"
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #find(data) ⇒ Object
-
#initialize(url) ⇒ Jenkins
constructor
A new instance of Jenkins.
Constructor Details
#initialize(url) ⇒ Jenkins
Returns a new instance of Jenkins.
13 14 15 |
# File 'lib/bukin/jenkins.rb', line 13 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/bukin/jenkins.rb', line 8 def url @url end |
Instance Method Details
#find(data) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bukin/jenkins.rb', line 17 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 |