Class: Artifactory::Resource::Artifact

Inherits:
Base
  • Object
show all
Defined in:
lib/artifactory/resources/artifact.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

attribute, attributes, #attributes, #client, #client=, #client?, #extract_client!, extract_client!, find_from_config, format_repos!, #format_repos!, from_url, has_attribute?, #initialize, #inspect, list_from_config, #set, #to_hash, #to_json, #to_matrix_properties, #to_query_string_parameters, #to_s, url_safe, #url_safe

Constructor Details

This class inherits a constructor from Artifactory::Resource::Base

Class Method Details

.checksum_search(options = {}) ⇒ Array<Resource::Artifact>

Search for an artifact by its checksum

Examples:

Search for all repositories with the given MD5 checksum

Artifact.checksum_search(
  md5: 'abcd1234...',
)

Search for all artifacts with the given SHA1 checksum in a repo

Artifact.checksum_search(
  sha1: 'abcdef123456....',
  repos: 'libs-release-local',
)

Parameters:

  • options (Hash) (defaults to: {})

    the list of options to search with

Options Hash (options):

  • :client (Artifactory::Client)

    the client object to make the request with

  • :md5 (String)

    the MD5 checksum of the artifact to search for

  • :sha1 (String)

    the SHA1 checksum of the artifact to search for

  • :repos (String, Array<String>)

    the list of repos to search

Returns:



179
180
181
182
183
184
185
186
187
# File 'lib/artifactory/resources/artifact.rb', line 179

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

.creation_search(options = {}) ⇒ Array<Resource::Artifact>

Search for an artifact by its creation date

Examples:

Search for all repositories with the given creation date range

Artifact.usage_search(
  from : 1414800000000,
  to   : 1414871200000,
)

Search for all artifacts with the given creation date range in a repo

Artifact.usage_search(
  from : 1414800000000,
  to   : 1414871200000,
  repos: 'libs-release-local',
)

Parameters:

  • options (Hash) (defaults to: {})

    the list of options to search with

Options Hash (options):

  • :client (Artifactory::Client)

    the client object to make the request with

  • :from (Long)

    the creation start date of the artifact to search for (millis since epoch)

  • :to (Long)

    the creation end date of the artifact to search for (millis since epoch)

  • :repos (String, Array<String>)

    the list of repos to search

Returns:



261
262
263
264
265
266
267
268
269
# File 'lib/artifactory/resources/artifact.rb', line 261

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

.from_hash(hash, options = {}) ⇒ Object

See Also:



365
366
367
368
369
370
371
372
# File 'lib/artifactory/resources/artifact.rb', line 365

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

.gavc_search(options = {}) ⇒ Array<Resource::Artifact>

Search for an artifact by Maven coordinates: Group ID, Artifact ID, Version and Classifier.

Examples:

Search for all repositories with the given gavc

Artifact.gavc_search(
  group:      'org.acme',
  name:       'artifact',
  version:    '1.0',
  classifier: 'sources',
)

Search for all artifacts with the given gavc in a specific repo

Artifact.gavc_search(
  group:      'org.acme',
  name:       'artifact',
  version:    '1.0',
  classifier: 'sources',
  repos:      'libs-release-local',
)

Parameters:

  • options (Hash) (defaults to: {})

    the list of options to search with

Options Hash (options):

  • :client (Artifactory::Client)

    the client object to make the request with

  • :group (String)

    the group id to search for

  • :name (String)

    the artifact id to search for

  • :version (String)

    the version of the artifact to search for

  • :classifier (String)

    the classifer to search for

  • :repos (String, Array<String>)

    the list of repos to search

Returns:



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/artifactory/resources/artifact.rb', line 95

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

.latest_version(options = {}) ⇒ String?

Get the latest version of an artifact.

Examples:

Find the latest version of an artifact

Artifact.latest_version(name: 'artifact')

Find the latest version of an artifact in a repo

Artifact.latest_version(
  name: 'artifact',
  repo: 'libs-release-local',
)

Find the latest snapshot version of an artifact

Artifact.latest_version(name: 'artifact', version: '1.0-SNAPSHOT')

Find the latest version of an artifact in a group

Artifact.latest_version(name: 'artifact', group: 'org.acme')

Parameters:

  • options (Hash) (defaults to: {})

    the list of options to search with

Options Hash (options):

  • :client (Artifactory::Client)

    the client object to make the request with

  • :group (String)

    the group id to search for

  • :name (String)

    the artifact id to search for

  • :version (String)

    the version of the artifact to search for

  • :remote (Boolean)

    search remote repos (default: false)

  • :repos (String, Array<String>)

    the list of repos to search

Returns:

  • (String, nil)

    the latest version as a string (e.g. 1.0-201203131455-2), or nil if no artifact matches the given query



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/artifactory/resources/artifact.rb', line 342

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

.property_search(options = {}) ⇒ Array<Resource::Artifact>

Search for an artifact by the given properties. These are arbitrary properties defined by the user on artifact, so the search uses a free- form schema.

Examples:

Search for all repositories with the given properties

Artifact.property_search(
  branch: 'master',
  author: 'sethvargo',
)

Search for all artifacts with the given gavc in a specific repo

Artifact.property_search(
  branch: 'master',
  author: 'sethvargo',
  repos: 'libs-release-local',
)

Parameters:

  • options (Hash) (defaults to: {})

    the free-form list of options to search with

Options Hash (options):

  • :client (Artifactory::Client)

    the client object to make the request with

  • :repos (String, Array<String>)

    the list of repos to search

Returns:



140
141
142
143
144
145
146
147
148
# File 'lib/artifactory/resources/artifact.rb', line 140

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

.search(options = {}) ⇒ Array<Resource::Artifact>

Search for an artifact by the full or partial filename.

Examples:

Search for all repositories with the name “artifact”

Artifact.search(name: 'artifact')

Search for all artifacts named “artifact” in a specific repo

Artifact.search(name: 'artifact', repos: 'libs-release-local')

Parameters:

  • options (Hash) (defaults to: {})

    the list of options to search with

Options Hash (options):

  • :client (Artifactory::Client)

    the client object to make the request with

  • :name (String)

    the name of the artifact to search (it can be a regular expression)

  • :repos (String, Array<String>)

    the list of repos to search

Returns:



45
46
47
48
49
50
51
52
53
# File 'lib/artifactory/resources/artifact.rb', line 45

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

.usage_search(options = {}) ⇒ Array<Resource::Artifact>

Search for an artifact by its usage

Examples:

Search for all repositories with the given usage statistics

Artifact.usage_search(
  notUsedSince: 1388534400000,
  createdBefore: 1388534400000,
)

Search for all artifacts with the given usage statistics in a repo

Artifact.usage_search(
  notUsedSince: 1388534400000,
  createdBefore: 1388534400000,
  repos: 'libs-release-local',
)

Parameters:

  • options (Hash) (defaults to: {})

    the list of options to search with

Options Hash (options):

  • :client (Artifactory::Client)

    the client object to make the request with

  • :notUsedSince (Long)

    the last downloaded cutoff date of the artifact to search for (millis since epoch)

  • :createdBefore (Long)

    the creation cutoff date of the artifact to search for (millis since epoch)

  • :repos (String, Array<String>)

    the list of repos to search

Returns:



220
221
222
223
224
225
226
227
228
# File 'lib/artifactory/resources/artifact.rb', line 220

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

.versions(options = {}) ⇒ Object

Get all versions of an artifact.

Examples:

Get all versions of a given artifact

Artifact.versions(name: 'artifact')

Get all versions of a given artifact in a specific repo

Artifact.versions(name: 'artifact', repos: 'libs-release-local')

Parameters:

  • options (Hash) (defaults to: {})

    the list of options to search with

Options Hash (options):

  • :client (Artifactory::Client)

    the client object to make the request with

  • :group (String)

    the

  • :sha1 (String)

    the SHA1 checksum of the artifact to search for

  • :repos (String, Array<String>)

    the list of repos to search



291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/artifactory/resources/artifact.rb', line 291

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

Instance Method Details

#checksumsObject

Return this object’s checksums

Returns:

  • (Object)


376
# File 'lib/artifactory/resources/artifact.rb', line 376

attribute :checksums

#checksums=(value) ⇒ Object

Set this object’s checksums

Parameters:

  • value (Object)

    the value to set for checksums

  • default (Object)

    the default value for this attribute



376
# File 'lib/artifactory/resources/artifact.rb', line 376

attribute :checksums

#checksums?Boolean

Determines if the checksums value exists and is truthy

Returns:

  • (Boolean)


376
# File 'lib/artifactory/resources/artifact.rb', line 376

attribute :checksums

#complianceHash<String, Array<Hash>>

Get compliance info for a given artifact path. The result includes license and vulnerabilities, if any.

**This requires the Black Duck addon to be enabled!**

Examples:

Get compliance info for an artifact

artifact.compliance #=> { 'licenses' => [{ 'name' => 'LGPL v3' }] }

Returns:

  • (Hash<String, Array<Hash>>)


467
468
469
# File 'lib/artifactory/resources/artifact.rb', line 467

def compliance
  @compliance ||= client.get(File.join("/api/compliance", relative_path))
end

#copy(destination, options = {}) ⇒ Object

See Also:

  • #copy_or_move


408
409
410
# File 'lib/artifactory/resources/artifact.rb', line 408

def copy(destination, options = {})
  copy_or_move(:copy, destination, options)
end

#createdObject

Return this object’s created

Returns:

  • (Object)


377
# File 'lib/artifactory/resources/artifact.rb', line 377

attribute :created

#created=(value) ⇒ Object

Set this object’s created

Parameters:

  • value (Object)

    the value to set for created

  • default (Object)

    the default value for this attribute



377
# File 'lib/artifactory/resources/artifact.rb', line 377

attribute :created

#created?Boolean

Determines if the created value exists and is truthy

Returns:

  • (Boolean)


377
# File 'lib/artifactory/resources/artifact.rb', line 377

attribute :created

#deleteBoolean

Delete this artifact from repository, suppressing any ResourceNotFound exceptions might occur.

Returns:

  • (Boolean)

    true if the object was deleted successfully, false otherwise



419
420
421
422
423
# File 'lib/artifactory/resources/artifact.rb', line 419

def delete
  !!client.delete(download_uri)
rescue Error::HTTPError
  false
end

#download(target = Dir.mktmpdir, options = {}) ⇒ String

Download the artifact onto the local disk.

Examples:

Download an artifact

artifact.download #=> /tmp/cache/000adad0-bac/artifact.deb

Download a remote artifact into a specific target

artifact.download('~/Desktop') #=> ~/Desktop/artifact.deb

Parameters:

  • target (String) (defaults to: Dir.mktmpdir)

    the target directory where the artifact should be downloaded to (defaults to a temporary directory). **It is the user’s responsibility to cleanup the temporary directory when finished!**

  • options (Hash) (defaults to: {})

Options Hash (options):

  • filename (String)

    the name of the file when downloaded to disk (defaults to the basename of the file on the server)

Returns:

  • (String)

    the path where the file was downloaded on disk



492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
# File 'lib/artifactory/resources/artifact.rb', line 492

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.exist?(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

#download_uriObject

Return this object’s download_uri

Returns:

  • (Object)


378
# File 'lib/artifactory/resources/artifact.rb', line 378

attribute :download_uri, -> { raise "Download URI missing!" }

#download_uri=(value) ⇒ Object

Set this object’s download_uri

Parameters:

  • value (Object)

    the value to set for download_uri

  • default (Object)

    the default value for this attribute



378
# File 'lib/artifactory/resources/artifact.rb', line 378

attribute :download_uri, -> { raise "Download URI missing!" }

#download_uri?Boolean

Determines if the download_uri value exists and is truthy

Returns:

  • (Boolean)


378
# File 'lib/artifactory/resources/artifact.rb', line 378

attribute :download_uri, -> { raise "Download URI missing!" }

#keyObject

Return this object’s key

Returns:

  • (Object)


379
# File 'lib/artifactory/resources/artifact.rb', line 379

attribute :key

#key=(value) ⇒ Object

Set this object’s key

Parameters:

  • value (Object)

    the value to set for key

  • default (Object)

    the default value for this attribute



379
# File 'lib/artifactory/resources/artifact.rb', line 379

attribute :key

#key?Boolean

Determines if the key value exists and is truthy

Returns:

  • (Boolean)


379
# File 'lib/artifactory/resources/artifact.rb', line 379

attribute :key

#last_modifiedObject

Return this object’s last_modified

Returns:

  • (Object)


380
# File 'lib/artifactory/resources/artifact.rb', line 380

attribute :last_modified

#last_modified=(value) ⇒ Object

Set this object’s last_modified

Parameters:

  • value (Object)

    the value to set for last_modified

  • default (Object)

    the default value for this attribute



380
# File 'lib/artifactory/resources/artifact.rb', line 380

attribute :last_modified

#last_modified?Boolean

Determines if the last_modified value exists and is truthy

Returns:

  • (Boolean)


380
# File 'lib/artifactory/resources/artifact.rb', line 380

attribute :last_modified

#last_updatedObject

Return this object’s last_updated

Returns:

  • (Object)


381
# File 'lib/artifactory/resources/artifact.rb', line 381

attribute :last_updated

#last_updated=(value) ⇒ Object

Set this object’s last_updated

Parameters:

  • value (Object)

    the value to set for last_updated

  • default (Object)

    the default value for this attribute



381
# File 'lib/artifactory/resources/artifact.rb', line 381

attribute :last_updated

#last_updated?Boolean

Determines if the last_updated value exists and is truthy

Returns:

  • (Boolean)


381
# File 'lib/artifactory/resources/artifact.rb', line 381

attribute :last_updated

#local_pathObject

Return this object’s local_path

Returns:

  • (Object)


382
# File 'lib/artifactory/resources/artifact.rb', line 382

attribute :local_path, -> { raise "Local destination missing!" }

#local_path=(value) ⇒ Object

Set this object’s local_path

Parameters:

  • value (Object)

    the value to set for local_path

  • default (Object)

    the default value for this attribute



382
# File 'lib/artifactory/resources/artifact.rb', line 382

attribute :local_path, -> { raise "Local destination missing!" }

#local_path?Boolean

Determines if the local_path value exists and is truthy

Returns:

  • (Boolean)


382
# File 'lib/artifactory/resources/artifact.rb', line 382

attribute :local_path, -> { raise "Local destination missing!" }

#md5String

The MD5 of this artifact.

Returns:

  • (String)


401
402
403
# File 'lib/artifactory/resources/artifact.rb', line 401

def md5
  checksums && checksums["md5"]
end

#mime_typeObject

Return this object’s mime_type

Returns:

  • (Object)


383
# File 'lib/artifactory/resources/artifact.rb', line 383

attribute :mime_type

#mime_type=(value) ⇒ Object

Set this object’s mime_type

Parameters:

  • value (Object)

    the value to set for mime_type

  • default (Object)

    the default value for this attribute



383
# File 'lib/artifactory/resources/artifact.rb', line 383

attribute :mime_type

#mime_type?Boolean

Determines if the mime_type value exists and is truthy

Returns:

  • (Boolean)


383
# File 'lib/artifactory/resources/artifact.rb', line 383

attribute :mime_type

#move(destination, options = {}) ⇒ Object

See Also:

  • Artifactory::Resource::Artifact.{Artifact{Artifact#copy_or_move}


428
429
430
# File 'lib/artifactory/resources/artifact.rb', line 428

def move(destination, options = {})
  copy_or_move(:move, destination, options)
end

#properties(props = nil) ⇒ Hash<String, Object>

Set properties for this object. If no properties are given it lists the properties for this object.

Examples:

List all properties for an artifact

artifact.properties #=> { 'licenses'=>['Apache-2.0'] }

Set new properties for an artifact

artifact.properties(maintainer: 'SuperStartup01') #=> { 'licenses'=>['Apache-2.0'], 'maintainer'=>'SuperStartup01' }

Parameters:

  • props (Hash<String, Object>) (defaults to: nil)

    (default: nil) A hash of properties and corresponding values to set for the artifact

Returns:

  • (Hash<String, Object>)

    the list of properties



447
448
449
450
451
452
453
454
# File 'lib/artifactory/resources/artifact.rb', line 447

def properties(props = nil)
  if props.nil? || props.empty?
    get_properties
  else
    set_properties(props)
    get_properties(true)
  end
end

#repoObject

Return this object’s repo

Returns:

  • (Object)


384
# File 'lib/artifactory/resources/artifact.rb', line 384

attribute :repo

#repo=(value) ⇒ Object

Set this object’s repo

Parameters:

  • value (Object)

    the value to set for repo

  • default (Object)

    the default value for this attribute



384
# File 'lib/artifactory/resources/artifact.rb', line 384

attribute :repo

#repo?Boolean

Determines if the repo value exists and is truthy

Returns:

  • (Boolean)


384
# File 'lib/artifactory/resources/artifact.rb', line 384

attribute :repo

#sha1String

The SHA of this artifact.

Returns:

  • (String)


392
393
394
# File 'lib/artifactory/resources/artifact.rb', line 392

def sha1
  checksums && checksums["sha1"]
end

#sizeObject

Return this object’s size

Returns:

  • (Object)


385
# File 'lib/artifactory/resources/artifact.rb', line 385

attribute :size

#size=(value) ⇒ Object

Set this object’s size

Parameters:

  • value (Object)

    the value to set for size

  • default (Object)

    the default value for this attribute



385
# File 'lib/artifactory/resources/artifact.rb', line 385

attribute :size

#size?Boolean

Determines if the size value exists and is truthy

Returns:

  • (Boolean)


385
# File 'lib/artifactory/resources/artifact.rb', line 385

attribute :size

#upload(repo, remote_path, properties = {}, headers = {}) ⇒ Resource::Artifact

Upload an artifact into the repository. If the first parameter is a File object, that file descriptor is passed to the uploader. If the first parameter is a string, it is assumed to be the path to a local file on disk. This method will automatically construct the File object from the given path.

Examples:

Upload an artifact from a File instance

artifact = Artifact.new(local_path: '/local/path/to/file.deb')
artifact.upload('libs-release-local', '/remote/path')

Upload an artifact with matrix properties

artifact = Artifact.new(local_path: '/local/path/to/file.deb')
artifact.upload('libs-release-local', '/remote/path', {
  status: 'DEV',
  rating: 5,
  branch: 'master'
})

Parameters:

  • repo (String)

    the key of the repository to which to upload the file

  • remote_path (String)

    the path where this resource will live in the remote artifactory repository, relative to the repository key

  • headers (Hash) (defaults to: {})

    the list of headers to send with the request

  • properties (Hash) (defaults to: {})

    a list of matrix properties

Returns:

See Also:

  • Artifactory Matrix Properties


546
547
548
549
550
551
552
553
554
555
556
557
558
559
# File 'lib/artifactory/resources/artifact.rb', line 546

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

#upload_checksum(repo, remote_path, type, value) ⇒ true

Upload the checksum for this artifact. **The artifact must already be uploaded or Artifactory will throw an exception!**.

Examples:

Set an artifact’s md5

artifact = Artifact.new(local_path: '/local/path/to/file.deb')
artifact.upload_checksum('libs-release-local', '/remote/path', :md5, 'ABCD1234')

Parameters:

  • type (Symbol)

    the type of checksum to write (md5 or sha1)

  • value (String)

    the actual checksum

  • repo (String)

    the key of the repository to which to upload the file

  • remote_path (String)

    the path where this resource will live in the remote artifactory repository, relative to the repository key

  • headers (Hash)

    the list of headers to send with the request

  • properties (Hash)

    a list of matrix properties

Returns:

  • (true)


577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
# File 'lib/artifactory/resources/artifact.rb', line 577

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

#upload_from_archive(repo, remote_path, properties = {}) ⇒ Object

Upload an artifact with the given archive. Consult the artifactory documentation for the format of the archive to upload.

Examples:

Upload an artifact with a checksum

artifact = Artifact.new(local_path: '/local/path/to/file.deb')
artifact.upload_from_archive('/remote/path')

See Also:



627
628
629
630
631
# File 'lib/artifactory/resources/artifact.rb', line 627

def upload_from_archive(repo, remote_path, properties = {})
  upload(repo, remote_path, properties,
    "X-Explode-Archive" => true
  )
end

#upload_with_checksum(repo, remote_path, checksum, properties = {}) ⇒ Object

Upload an artifact with the given SHA checksum. Consult the artifactory documentation for the possible responses when the checksums fail to match.

Examples:

Upload an artifact with a checksum

artifact = Artifact.new(local_path: '/local/path/to/file.deb')
artifact.upload_with_checksum('libs-release-local', /remote/path', 'ABCD1234')

Parameters:

  • checksum (String)

    the SHA1 checksum of the artifact to upload

  • repo (String)

    the key of the repository to which to upload the file

  • remote_path (String)

    the path where this resource will live in the remote artifactory repository, relative to the repository key

  • headers (Hash)

    the list of headers to send with the request

  • properties (Hash) (defaults to: {})

    a list of matrix properties

See Also:



608
609
610
611
612
613
# File 'lib/artifactory/resources/artifact.rb', line 608

def upload_with_checksum(repo, remote_path, checksum, properties = {})
  upload(repo, remote_path, properties,
    "X-Checksum-Deploy" => true,
    "X-Checksum-Sha1"   => checksum
  )
end

#uriObject

Return this object’s uri

Returns:

  • (Object)


375
# File 'lib/artifactory/resources/artifact.rb', line 375

attribute :uri, -> { raise "API path missing!" }

#uri=(value) ⇒ Object

Set this object’s uri

Parameters:

  • value (Object)

    the value to set for uri

  • default (Object)

    the default value for this attribute



375
# File 'lib/artifactory/resources/artifact.rb', line 375

attribute :uri, -> { raise "API path missing!" }

#uri?Boolean

Determines if the uri value exists and is truthy

Returns:

  • (Boolean)


375
# File 'lib/artifactory/resources/artifact.rb', line 375

attribute :uri, -> { raise "API path missing!" }