lib/packaging/util/ship.rb in packaging-0.108.2 vs lib/packaging/util/ship.rb in packaging-0.109.0

- old
+ new

@@ -375,11 +375,11 @@ ezbake_manifest = File.join('ext', 'ezbake.manifest') if File.exist?(ezbake_manifest) FileUtils.cp(ezbake_manifest, File.join(local_directory, "#{Pkg::Config.ref}.ezbake.manifest")) end ezbake_yaml = File.join("ext", "ezbake.manifest.yaml") - if File.exists?(ezbake_yaml) + if File.exist?(ezbake_yaml) FileUtils.cp(ezbake_yaml, File.join(local_directory, "#{Pkg::Config.ref}.ezbake.manifest.yaml")) end # Inside build_metadata*.json files there is additional metadata containing # information such as git ref and dependencies that are needed at build @@ -476,11 +476,12 @@ end def ship_to_artifactory(local_directory = 'pkg') Pkg::Util::File.fetch unless Pkg::Config.project - fail "You must set the 'project' in build_defaults.yaml or with the 'PROJECT_OVERRIDE' environment variable." + fail 'Project missing. Set it with the "project" key in build_defaults.yaml or ' \ + 'with the "PROJECT_OVERRIDE" environment variable.' end artifactory = Pkg::ManageArtifactory.new(Pkg::Config.project, Pkg::Config.ref) artifacts = Dir.glob("#{local_directory}/**/*").reject { |e| File.directory? e } artifacts.sort! do |a, b| @@ -490,16 +491,25 @@ -1 else a <=> b end end + artifacts.each do |artifact| - if File.extname(artifact) == ".yaml" || File.extname(artifact) == ".json" + # Always ship .yaml and .jsons even if they already exist + if %w[.yaml .json].include? File.extname(artifact) artifactory.deploy_package(artifact) - elsif artifactory.package_exists_on_artifactory?(artifact) - warn "Attempt to upload '#{artifact}' failed. Package already exists!" - else - artifactory.deploy_package(artifact) + next end + + # Warn against anything that already exists + existing = artifactory.artifact_paths(artifact) + if existing.any? + warn "Uploading '#{artifact}' to Artifactory refused. " \ + "Package already exists here: #{existing.join(', ')}" + next + end + + artifactory.deploy_package(artifact) end end end