class Artifactory::Resource::Artifact

def checksum_search(options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :repos (String, Array) --
  • :sha1 (String) --
  • :md5 (String) --
  • :client (Artifactory::Client) --

Parameters:
  • options (Hash) --

Other tags:
    Example: Search for all artifacts with the given SHA1 checksum in a repo -
    Example: Search for all repositories with the given MD5 checksum -
def checksum_search(options = {})
  client = extract_client!(options)
  params = Util.slice(options, :md5, :sha1, :repos)
  format_repos!(params)
  client.get("/api/search/checksum", params)["results"].map do |artifact|
    from_url(artifact["uri"], client: client)
  end
end

def compliance

Returns:
  • (Hash>) -

Other tags:
    Example: Get compliance info for an artifact -
def compliance
  @compliance ||= client.get(File.join("/api/compliance", relative_path))
end

def copy(destination, options = {})

Other tags:
    See: Artifact#copy_or_move -
def copy(destination, options = {})
  copy_or_move(:copy, destination, options)
end

def copy_or_move(action, destination, options = {})

Returns:
  • (Hash) -

Options Hash: (**options)
  • :dry_run (Boolean) --
  • :suppress_layouts (Boolean) --
  • :fail_fast (Boolean) --

Parameters:
  • options (Hash) --
  • destination (String) --
  • action (Symbol) --

Other tags:
    Example: Copy the current artifact to +ext-releases-local+ -
    Example: Move the current artifact to +ext-releases-local+ -
def copy_or_move(action, destination, options = {})
  params = {}.tap do |param|
    param[:to]              = destination
    param[:failFast]        = 1 if options[:fail_fast]
    param[:suppressLayouts] = 1 if options[:suppress_layouts]
    param[:dry]             = 1 if options[:dry_run]
  end
  endpoint = File.join("/api", action.to_s, relative_path) + "?#{to_query_string_parameters(params)}"
  client.post(endpoint, {})
end

def creation_search(options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :repos (String, Array) --
  • :to (Long) --
  • :from (Long) --
  • :client (Artifactory::Client) --

Parameters:
  • options (Hash) --

Other tags:
    Example: Search for all artifacts with the given creation date range in a repo -
    Example: Search for all repositories with the given creation date range -
def creation_search(options = {})
  client = extract_client!(options)
  params = Util.slice(options, :from, :to, :repos)
  format_repos!(params)
  client.get("/api/search/creation", params)["results"].map do |artifact|
    from_url(artifact["uri"], client: client)
  end
end

def delete

Returns:
  • (Boolean) -
def delete
  !!client.delete(download_uri)
rescue Error::HTTPError
  false
end

def download(target = Dir.mktmpdir, options = {})

Returns:
  • (String) -

Options Hash: (**options)
  • filename (String) --

Parameters:
  • options (Hash) --
  • target (String) --

Other tags:
    Example: Download a remote artifact into a specific target -
    Example: Download an artifact -
def download(target = Dir.mktmpdir, options = {})
  target = File.expand_path(target)
  # Make the directory if it doesn't yet exist
  FileUtils.mkdir_p(target) unless File.exists?(target)
  # Use the server artifact's filename if one wasn't given
  filename = options[:filename] || File.basename(download_uri)
  # Construct the full path for the file
  destination = File.join(target, filename)
  File.open(destination, "wb") do |file|
    client.get(download_uri) do |chunk|
      file.write chunk
    end
  end
  destination
end

def from_hash(hash, options = {})

Other tags:
    See: Artifactory::Resource::Base.from_hash -
def from_hash(hash, options = {})
  super.tap do |instance|
    instance.created       = Time.parse(instance.created) rescue nil
    instance.last_modified = Time.parse(instance.last_modified) rescue nil
    instance.last_updated  = Time.parse(instance.last_updated)  rescue nil
    instance.size          = instance.size.to_i
  end
end

def gavc_search(options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :repos (String, Array) --
  • :classifier (String) --
  • :version (String) --
  • :name (String) --
  • :group (String) --
  • :client (Artifactory::Client) --

Parameters:
  • options (Hash) --

Other tags:
    Example: Search for all artifacts with the given gavc in a specific repo -
    Example: Search for all repositories with the given gavc -
def gavc_search(options = {})
  client = extract_client!(options)
  options = Util.rename_keys(options,
    :group      => :g,
    :name       => :a,
    :version    => :v,
    :classifier => :c
  )
  params = Util.slice(options, :g, :a, :v, :c, :repos)
  format_repos!(params)
  client.get("/api/search/gavc", params)["results"].map do |artifact|
    from_url(artifact["uri"], client: client)
  end
end

def get_properties(refresh_cache = false)

Returns:
  • (Hash) -

Parameters:
  • refresh_cache (TrueClass, FalseClass) -- (default: +false+)

Other tags:
    Example: List all properties for an artifact -
def get_properties(refresh_cache = false)
  if refresh_cache || @properties.nil?
    @properties = client.get(File.join("/api/storage", relative_path), properties: nil)["properties"]
  end
  @properties
end

def latest_version(options = {})

Returns:
  • (String, nil) -

Options Hash: (**options)
  • :repos (String, Array) --
  • :remote (Boolean) --
  • :version (String) --
  • :name (String) --
  • :group (String) --
  • :client (Artifactory::Client) --

Parameters:
  • options (Hash) --

Other tags:
    Example: Find the latest version of an artifact in a group -
    Example: Find the latest snapshot version of an artifact -
    Example: Find the latest version of an artifact in a repo -
    Example: Find the latest version of an artifact -
def latest_version(options = {})
  client = extract_client!(options)
  options = Util.rename_keys(options,
    :group   => :g,
    :name    => :a,
    :version => :v
  )
  params = Util.slice(options, :g, :a, :v, :repos, :remote)
  format_repos!(params)
  # For whatever reason, Artifactory won't accept "true" - they want a
  # literal "1"...
  params[:remote] = 1 if options[:remote]
  client.get("/api/search/latestVersion", params)
rescue Error::HTTPError => e
  raise unless e.code == 404
  nil
end

def md5

Returns:
  • (String) -
def md5
  checksums && checksums["md5"]
end

def move(destination, options = {})

Other tags:
    See: {Artifact#copy_or_move} -
def move(destination, options = {})
  copy_or_move(:move, destination, options)
end

def properties(props = nil)

Returns:
  • (Hash) -

Parameters:
  • props (Hash) -- (default: +nil+)

Other tags:
    Example: Set new properties for an artifact -
    Example: List all properties for an artifact -
def properties(props = nil)
  if props.nil? || props.empty?
    get_properties
  else
    set_properties(props)
    get_properties(true)
  end
end

def property_search(options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :repos (String, Array) --
  • :client (Artifactory::Client) --

Parameters:
  • options (Hash) --

Other tags:
    Example: Search for all artifacts with the given gavc in a specific repo -
    Example: Search for all repositories with the given properties -
def property_search(options = {})
  client = extract_client!(options)
  params = options.dup
  format_repos!(params)
  client.get("/api/search/prop", params)["results"].map do |artifact|
    from_url(artifact["uri"], client: client)
  end
end

def relative_path

Returns:
  • (String) -

Other tags:
    Example: Get the relative URI from the resource -
def relative_path
  @relative_path ||= uri.split("/api/storage", 2).last
end

def search(options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :repos (String, Array) --
  • :name (String) --
  • :client (Artifactory::Client) --

Parameters:
  • options (Hash) --

Other tags:
    Example: Search for all artifacts named "artifact" in a specific repo -
    Example: Search for all repositories with the name "artifact" -
def search(options = {})
  client = extract_client!(options)
  params = Util.slice(options, :name, :repos)
  format_repos!(params)
  client.get("/api/search/artifact", params)["results"].map do |artifact|
    from_url(artifact["uri"], client: client)
  end
end

def set_properties(properties)

Returns:
  • (Hash) -

Parameters:
  • properties (Hash) --

Other tags:
    Example: Set properties for an artifact -
def set_properties(properties)
  matrix = to_matrix_properties(properties)
  endpoint = File.join("/api/storage", relative_path) + "?properties=#{matrix}"
  client.put(endpoint, nil)
end

def sha1

Returns:
  • (String) -
def sha1
  checksums && checksums["sha1"]
end

def upload(repo, remote_path, properties = {}, headers = {})

Returns:
  • (Resource::Artifact) -

Parameters:
  • properties (Hash) --
  • headers (Hash) --
  • remote_path (String) --
  • repo (String) --

Other tags:
    Example: Upload an artifact with matrix properties -
    Example: Upload an artifact from a File instance -

Other tags:
    See: bit.ly/1dhJRMO - Artifactory Matrix Properties
def upload(repo, remote_path, properties = {}, headers = {})
  file     = File.new(File.expand_path(local_path))
  matrix   = to_matrix_properties(properties)
  endpoint = File.join("#{url_safe(repo)}#{matrix}", remote_path)
  # Include checksums in headers if given.
  headers["X-Checksum-Md5"] = md5   if md5
  headers["X-Checksum-Sha1"] = sha1 if sha1
  response = client.put(endpoint, file, headers)
  return unless response.is_a?(Hash)
  self.class.from_hash(response)
end

def upload_checksum(repo, remote_path, type, value)

Returns:
  • (true) -

Parameters:
  • value (String) --
  • type (Symbol) --
  • () --

Other tags:
    Example: Set an artifact's md5 -
def upload_checksum(repo, remote_path, type, value)
  file = Tempfile.new("checksum.#{type}")
  file.write(value)
  file.rewind
  endpoint = File.join(url_safe(repo), "#{remote_path}.#{type}")
  client.put(endpoint, file)
  true
ensure
  if file
    file.close
    file.unlink
  end
end

def upload_from_archive(repo, remote_path, properties = {})

Parameters:
  • () --

Other tags:
    Example: Upload an artifact with a checksum -

Other tags:
    See: Artifact#upload - More syntax examples
def upload_from_archive(repo, remote_path, properties = {})
  upload(repo, remote_path, properties,
    "X-Explode-Archive" => true
  )
end

def upload_with_checksum(repo, remote_path, checksum, properties = {})

Parameters:
  • checksum (String) --
  • () --

Other tags:
    Example: Upload an artifact with a checksum -

Other tags:
    See: Artifact#upload - More syntax examples
def upload_with_checksum(repo, remote_path, checksum, properties = {})
  upload(repo, remote_path, properties,
    "X-Checksum-Deploy" => true,
    "X-Checksum-Sha1"   => checksum
  )
end

def usage_search(options = {})

Returns:
  • (Array) -

Options Hash: (**options)
  • :repos (String, Array) --
  • :createdBefore (Long) --
  • :notUsedSince (Long) --
  • :client (Artifactory::Client) --

Parameters:
  • options (Hash) --

Other tags:
    Example: Search for all artifacts with the given usage statistics in a repo -
    Example: Search for all repositories with the given usage statistics -
def usage_search(options = {})
  client = extract_client!(options)
  params = Util.slice(options, :notUsedSince, :createdBefore, :repos)
  format_repos!(params)
  client.get("/api/search/usage", params)["results"].map do |artifact|
    from_url(artifact["uri"], client: client)
  end
end

def versions(options = {})

Options Hash: (**options)
  • :repos (String, Array) --
  • :sha1 (String) --
  • :group (String) --
  • :client (Artifactory::Client) --

Parameters:
  • options (Hash) --

Other tags:
    Example: Get all versions of a given artifact in a specific repo -
    Example: Get all versions of a given artifact -
def versions(options = {})
  client  = extract_client!(options)
  options = Util.rename_keys(options,
    :group   => :g,
    :name    => :a,
    :version => :v
  )
  params = Util.slice(options, :g, :a, :v, :repos)
  format_repos!(params)
  client.get("/api/search/versions", params)["results"]
rescue Error::HTTPError => e
  raise unless e.code == 404
  []
end