脚本方式本地仓库jar包批量导入maven私服(亲测有效)

1.脚本内容,将以下内容保存为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}/{} ;

  

2.git上执行./mavenimport.sh -u admin -p admin123 -r http://10.64.39.86:8081/nexus/content/repositories/scrk_public/

./mavenimport.sh -u admin -p admin123 -r http://10.64.39.86:8081/nexus/content/repositories/scrk_public/

注:admin/admin123为私服账号密码 http........为私服文件保存路径

posted @ 2021-12-22 10:46  转转龙  阅读(1011)  评论(0编辑  收藏  举报