Skip to content

Instantly share code, notes, and snippets.

@realityforge
Created August 9, 2016 03:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save realityforge/d9c15cb6eedea0b12ab81abe08a5155c to your computer and use it in GitHub Desktop.
Save realityforge/d9c15cb6eedea0b12ab81abe08a5155c to your computer and use it in GitHub Desktop.
Copy artifacts from one Maven repository to another
#!/usr/bin/env ruby
require 'fileutils'
# Run this form the directory that is being uploaded.
# It will delete the file as it goes
USER='user'
PASSWORD='password'
REPO='repo.example.com/repository/thirdparty'
`find * -type f ! -name run.rb ! -name '*.md5' ! -name '*.sha1' ! -name 'maven-metadata.xml' ! -name '*.asc' ! -name 'archetype-catalog.xml'`.split("\n").each do |f|
puts "Uploading #{f}"
command = "curl --fail -X PUT http://#{USER}:#{PASSWORD}@#{REPO}/#{f} --upload-file #{f}"
puts command
system(command)
if $?.exitstatus == 0
puts "Completed upload of #{f}"
FileUtils.rm_f f
else
puts "Failed to upload #{f}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment