Downloading From Artifactory

This wraps the RepositoryArtifact and RepositoryArtifactCollection resources for downloading artifacts from the Artifactory server

Usage with target directory

Download method returns a list of remote File resources downloaded from artifactory. Artifactory file together with its dependencies will be downloaded to the target directory.

require 'mintpress-resources'

opts = {
  :host => MintPress::Infrastructure::LocalHost.new,
  'groupId' => 'com.limepoint',
  'artifactId' => 'EnvMintModelProcessor',
  'version' => '3.0.0',
  'repo' => 'environmint-local',
  'target_dir' => '/tmp',
  'artifactory_url' => 'https://artifactory.mintpress.io/artifactory',
  'artifactory_username' => ENV['ARTIFACTORY_USERNAME'],
  'artifactory_password' => ENV['ARTIFACTORY_PASSWORD']
}

files = MintPress::Resources::RepositoryArtifact.new(opts).download
puts files[0].path unless files.empty?

Usage with target filename

For a single file download, specifying target_filename allows users to rename downloaded file.

require 'mintpress-resources'

opts = {
  :host => MintPress::Infrastructure::LocalHost.new,
  'groupId' => 'com.limepoint',
  'artifactId' => 'EnvMintModelProcessor',
  'version' => '3.0.0',
  'repo' => 'environmint-local',
  'target_dir' => '/tmp',
  'target_filename' => 'processor.jar',
  'artifactory_url' => 'https://artifactory.mintpress.io/artifactory',
  'artifactory_username' => ENV['ARTIFACTORY_USERNAME'],
  'artifactory_password' => ENV['ARTIFACTORY_PASSWORD']
}

files = MintPress::Resources::RepositoryArtifact.new(opts).download

Downloading collection of artifacts

Using RepositoryArtifactCollection class allows user to configure a collection of artifacts to download. Attributes ‘groupId’, ‘version’ and ‘repo’ provide default values when these attributes are not specified for each ‘artifacts’ item. Attribute ‘target_filename’ can be given for the individual artifact to rename downloaded file.

require 'mintpress-resources'

opts = {
  :host => MintPress::Infrastructure::LocalHost.new,
  'groupId' => 'com.limepoint',
  'artifacts' => [
    { 'artifactId' => 'EnvMintPlugin', 'target_dir' => '/tmp/dir1/nested', 'target_filename' => 'plugin.jar' },
    { 'artifactId' => 'EnvMintModelProcessor', 'version' => '3.0.0' },
    { 'artifactId' => 'EnvironMint-DesignTime-Data', 'version' => '3.7.2', 'repo' => 'environmint-ui-local' },
  ],
  'version' => '3.7.1',
  'repo' => 'environmint-local',
  'target_dir' => '/tmp/default',
  'artifactory_url' => 'https://artifactory.mintpress.io/artifactory',
  'artifactory_username' => ENV['ARTIFACTORY_USERNAME'],
  'artifactory_password' => ENV['ARTIFACTORY_PASSWORD']
}

files = MintPress::Resources::RepositoryArtifactCollection.new(opts).download

Printing Checksums of Downloaded Files

MintPress provides access to the MD5, SHA1 and SHA256 checksums of downloaded files. These methods are only available for MintPress::Resources::RepositoryArtifact class and will work for both target directory and target file cases.

require 'mintpress-resources'

opts = {
  :host => MintPress::Infrastructure::LocalHost.new,
  'groupId' => 'com.limepoint',
  'artifactId' => 'EnvMintModelProcessor',
  'version' => '3.0.0',
  'repo' => 'environmint-local',
  'target_dir' => '/tmp',
  'artifactory_url' => 'https://artifactory.mintpress.io/artifactory',
  'artifactory_username' => ENV['ARTIFACTORY_USERNAME'],
  'artifactory_password' => ENV['ARTIFACTORY_PASSWORD']
}

files = MintPress::Resources::RepositoryArtifact.new(opts).download

# You can use the `downloaded_files` method which returns the name and a handler to the file object as a Hash.
puts "************* Printing Checksums for downloaded files"
artifact.downloaded_files.each do | name, handler |
  puts "Filename: #{name}"
  puts "MD5: #{handler.md5}"
  puts "SHA1: #{handler.sha1}"
  puts "SHA256: #{handler.sha256}"
end

# You can also use the `downloaded_list` method which returns the file object as an array.
puts "************* Printing Checksums for downloaded files using downloaded_list"
artifact.downloaded_list.each do | handler |
  puts "Filename: #{handler.name}"
  puts "MD5: #{handler.md5}"
  puts "SHA1: #{handler.sha1}"
  puts "SHA256: #{handler.sha256}"
end