Created
August 9, 2016 03:31
-
-
Save realityforge/d9c15cb6eedea0b12ab81abe08a5155c to your computer and use it in GitHub Desktop.
Copy artifacts from one Maven repository to another
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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