Batch upload the jar package of the local Maven warehouse to the Nexus private server

The steps are as follows:
1. First type a complete zip package of the local maven/localrepository warehouse
2. Upload it to the linux directory, such as: /opt
3. Unzip localrepository.zip
4. Enter the /opt/localrepository directory
5.1-4 steps, you can Upload the local localrepository directly to /opt/localrepository through FTP/SFTP tools
Insert picture description here
6. Create touch mavenimport.sh script and write the following;

#!/bin/bash
# copy and run this script to the root of the repository directory containing files
# this script attempts to exclude uploading itself explicitly so the script name is important
# Get command line params

while getopts ":r:u:p:" opt; do
	case $opt in
		r) REPO_URL="$OPTARG"
		;;
		u) USERNAME="$OPTARG"
		;;
		p) PASSWORD="$OPTARG"
		;;
	esac
done

find . -type f -not -path './mavenimport\.sh*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;

7. Enter chmod a+x mavenimport.sh for executable authorization
8. Execute import command (note: change the address to your own private server address)

./mavenimport.sh -u admin -p admin123 -r http://192.168.92.11:9999/nexus/content/repositories/thirdparty/

9. After all the import is complete, refresh on Nexus to see the imported jar
Insert picture description here

Guess you like

Origin blog.csdn.net/G_whang/article/details/111713272