lib/cicd/builder/mixlib/repo/artifactory.rb in cicd-builder-0.9.62 vs lib/cicd/builder/mixlib/repo/artifactory.rb in cicd-builder-0.9.63
- old
+ new
@@ -207,18 +207,29 @@
@logger.info "#{artifactory_endpoint()}/#{args[:repo] || artifactory_repo()}/#{artifact_path} exists - #{objects.size} results"
@logger.info "\t#{objects.map{|o| o.attributes[:uri]}.join("\n\t")}"
matched = matchArtifactoryObjects(artifact_path, data, objects)
upload ||= (matched.size == 0)
end
+ properties_matrix = {}
+ data.select{|k,_| not k.to_s.match(%r'^file')}.each do |k,v|
+ properties_matrix["product.#{k}"] = v
+ end
+ data[:properties] = properties_matrix.merge(@properties_matrix)
if upload
- properties_matrix = {}
- data.select{|k,_| not k.to_s.eql?('file')}.each do |k,v|
- properties_matrix["product.#{k}"] = v
- end
- data[:properties] = properties_matrix.merge(@properties_matrix)
objects = uploadArtifact(artifact_module, artifact_version, artifact_path, data, args[:repo])
matched = matchArtifactoryObjects(artifact_path, data, objects)
+ properties = matched.map{ |artifact|
+ artifact.properties
+ }
+ @logger.info "Matched artifacts properties: #{properties.ai}"
+ matched.each { |match|
+ artifact = ::Artifactory::Resource::Artifact.from_url(match.uri, client: @client)
+ unless artifact.uri =~ %r'#{data[:properties]['product.version']}/'
+ @logger.error "Artifact uploaded #{artifact_module}/#{artifact_version} to #{match.uri} does not contain #{data[:properties]['product.version']}/"
+ @vars[:return_code] = Errors::ARTIFACT_NOT_UPLOADED
+ end
+ }
else
@logger.info "Keep existing #{matched.map{|o| o.attributes[:uri]}.join("\t")}"
end
if data[:temp]
if File.exists?(data[:file])
@@ -236,16 +247,31 @@
artifact_path = getArtifactPath(artifact_module, artifact_version, artifact_name)
copies = maybeArtifactoryObject(artifact_module, artifact_version, false, args[:repo])
matched = matchArtifactoryObjects(artifact_path, data, copies)
upload = (matched.size == 0)
if upload
+ copies = []
objects.each do |artifact|
copied = copyArtifact(artifact_module, artifact_version, artifact_path, artifact, args[:repo])
unless copied.size > 0
@vars[:return_code] = Errors::ARTIFACT_NOT_COPIED
break
end
+ copies << copied
end
+ copies.flatten!
+ matched = matchArtifactoryObjects(artifact_path, data, copies)
+ properties = matched.map{ |artifact|
+ artifact.properties
+ }
+ @logger.info "Matched artifacts properties: #{properties.ai}"
+ matched.each { |match|
+ artifact = ::Artifactory::Resource::Artifact.from_url(match.uri, client: @client)
+ unless artifact.uri =~ %r'#{data[:properties]['product.version']}-#{data[:properties]['product.build']}/'
+ @logger.error "Artifact uploaded #{artifact_module}/#{artifact_version} to #{match.uri} does not contain #{data[:properties]['product.version']}-#{data[:properties]['product.version']}/"
+ @vars[:return_code] = Errors::ARTIFACT_NOT_UPLOADED
+ end
+ }
else
@logger.info "Keep existing #{matched.map{|o| o.attributes[:uri]}.join("\t")}"
end
end
args[:data] = data
\ No newline at end of file