Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Maven artifact classifers #92

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libraries/chef_artifact_nexus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def remote
#
# @return [String] the version number that latest resolves to or the passed in value
def get_actual_version(coordinates)
version = coordinates.split(':')[3]
if Chef::Artifact.latest?(version)
artifact = NexusCli::Artifact.new(coordinates)
if Chef::Artifact.latest?(artifact.version)
REXML::Document.new(remote.get_artifact_info(coordinates)).elements["//version"].text
else
version
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be artifact.version to handle cases where the version isn't 'latest'

Expand Down
18 changes: 10 additions & 8 deletions providers/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,14 @@ def load_current_resource

@nexus_configuration_object = new_resource.nexus_configuration
@nexus_connection = Chef::Artifact::Nexus.new(node, nexus_configuration_object)
group_id, artifact_id, extension = @new_resource.artifact_location.split(':')
@artifact_version = nexus_connection.get_actual_version([group_id, artifact_id, extension, @new_resource.version].join(':'))
@artifact_location = [group_id, artifact_id, extension, artifact_version].join(':')
coordinates = [@new_resource.artifact_location, @new_resource.version].join(':')
@artifact_version = nexus_connection.get_actual_version(coordinates)
artifact = NexusCli::Artifact.new(coordinates)
if artifact.classifier.nil?
@artifact_location = "#{artifact.group_id}:#{artifact.artifact_id}:#{artifact.extension}:#{artifact_version}"
else
@artifact_location = "#{artifact.group_id}:#{artifact.artifact_id}:#{artifact.extension}:#{artifact.classifier}:#{artifact_version}"
end
elsif Chef::Artifact.from_s3?(@new_resource.artifact_location)
unless Chef::Artifact.windows?
case node['platform_family']
Expand Down Expand Up @@ -266,11 +271,8 @@ def cached_tar_path
# @return [String] the artifacts filename
def artifact_filename
if Chef::Artifact.from_nexus?(new_resource.artifact_location)
group_id, artifact_id, extension, version = artifact_location.split(":")
unless extension
extension = "jar"
end
"#{artifact_id}-#{version}.#{extension}"
artifact = NexusCli::Artifact.new(artifact_location)
artifact.file_name
else
::File.basename(artifact_location)
end
Expand Down