本地jar包批量上传Nexus私服

背景:本地跑了个java微服务,需要把服务依赖的jar包上传到私服,批量传哦。服务器无法连接外网只能本地传。如果是一个很确认的jar直接在私服界面传即可。
1、把本地依赖的服务打成压缩包传到服务器上解压

手动传的zip压缩包

2、生成脚本,脚本名mavenimport.sh

#!/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}/{} ;

3、执行脚本即可传到私服中

chmod +x mavenimport.sh
./mavenimport.sh -u 仓库账号 -p 仓库密码 -r http://ip:port/repository/ylsh_maven/

举例

chmod +x mavenimport.sh
./mavenimport.sh -u root -p 123456 -r http://192.168.34.2:1000/repository/ylsh_maven/

你可能感兴趣的:(jar,maven,java)