批量上传本地Maven仓库jar包到Nexus私服
作者:互联网
步骤如下:
1.先将本地maven/localrepository仓库打一个完整的zip压缩包
2.上传到linux目录,如:/opt
3.解压localrepository.zip
4.进入/opt/localrepository目录
5.1-4步,可以通过FTP/SFTP工具,直接将本地localrepository上传到/opt/localrepository
6.创建touch 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}/{} ;
7.输入chmod a+x mavenimport.sh进行可执行授权
8.执行导入命令 (注意:将地址换成自己的私服地址)
./mavenimport.sh -u admin -p admin123 -r http://192.168.92.11:9999/nexus/content/repositories/thirdparty/
9.等待全部导入完毕后,在Nexus上刷新即可看到已导入的jar
标签:opt,xml,私服,jar,Maven,mavenimport,sh,path,localrepository 来源: https://blog.csdn.net/G_whang/article/details/111713272