Class: Omnibus::ArtifactoryPublisher
- Defined in:
- lib/omnibus/publishers/artifactory_publisher.rb
Instance Method Summary collapse
Methods inherited from Publisher
#initialize, #packages, publish
Methods included from Logging
Methods included from Digestable
#digest, #digest_directory, included
Constructor Details
This class inherits a constructor from Omnibus::Publisher
Instance Method Details
#publish(&block) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/omnibus/publishers/artifactory_publisher.rb', line 22 def publish(&block) log.info(log_key) { "Starting artifactory publisher" } safe_require("artifactory") packages.each do |package| # Make sure the package is good to go! log.debug(log_key) { "Validating '#{package.name}'" } package.validate! retries = Config.publish_retries begin upload_time = Benchmark.realtime do remote_path = remote_path_for(package) properties = default_properties.merge((package)) # Upload the package log.info(log_key) { "Uploading '#{package.name}'" } artifact_for(package).upload( repository, remote_path, properties ) # Upload the package's assoacited `*.metadata.json` file log.info(log_key) { "Uploading '#{package.name}.metadata.json'" } artifact_for(package.).upload( repository, "#{remote_path}.metadata.json", # *.metadata.json files should not include # the checksum properties properties.dup.delete_if { |k, v| k =~ /^omnibus\.(md5|sha)/ } ) end rescue Artifactory::Error::HTTPError => e if (retries -= 1) != 0 log.info(log_key) { "Upload failed with exception: #{e}" } log.info(log_key) { "Retrying failed publish #{retries} more time(s)..." } retry else raise e end end log.debug(log_key) { "Elapsed time to publish #{package.name}: #{1000 * upload_time} ms" } # If a block was given, "yield" the package to the caller yield(package) if block end if build_record? if packages.empty? log.warn(log_key) { "No packages were uploaded, build record will not be created." } else build_for(packages).save end end end |