欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

批量上传Maven仓库jar包到Nexus私服

程序员文章站 2022-03-29 21:04:55
批量上传Maven仓库jar包到Nexus私服1.先将本地maven/localrepository仓库打一个完整的zip压缩包2.上传到linux目录,如:/opt3.解压localrepository.zip到/opt路径下4.进入解压后的/opt/localrepository目录5.1-4步,可以通过FTP/SFTP工具,直接将本地localrepository上传到/opt/localrepository6.在/opt/localrepository目录下创建touch mavenim...

批量上传Maven仓库jar包到Nexus私服

1.先将本地maven/localrepository仓库打一个完整的zip压缩包

2.上传到linux目录,如:/opt

3.解压localrepository.zip到/opt路径下

4.进入解压后的/opt/localrepository目录

5.1-4步,可以通过FTP/SFTP工具,直接将本地localrepository上传到/opt/localrepository

6.在/opt/localrepository目录下创建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 optinr)REPOURL="opt in r) REPO_URL="OPTARG"
;;
u) USERNAME=“OPTARG";;p)PASSWORD="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:USERNAME:PASSWORD” -X PUT -v -T {} ${REPO_URL}/{} ;
7.输入chmod a+x mavenimport.sh进行可执行授权

8.执行导入命令 (注意:将地址换成自己的私服地址)

./mavenimport.sh -u admin -p admin123 -r http://ip:8081/repository/maven-releases/
9.等待全部导入完毕后,在Nexus上刷新即可看到已导入的jar
批量上传Maven仓库jar包到Nexus私服

本文地址:https://blog.csdn.net/txl12345678/article/details/107322896