批量将jar包上传到windows版nexus
将jar包打包成maven依赖
导入jar包地址到excel
获取jar包名
生成指令和pom依赖(需要有安装maven工具并配置环境变量)
="mvn install:install-file -DgroupId=com.xxx -DartifactId="&A1&" -Dversion=1.0 -Dpackaging=jar -Dfile="&A1&".jar
"
="<dependency>
<groupId>com.xxx</groupId>
<artifactId>"&A1&"</artifactId>
<version>1.0</version>
</dependency>"
填完公式将鼠标放到右下角往下拉即可生成每行指令
打包(会生成到maven)
会生成到\apache-maven-3.8.4\conf\settings.xml里配置的仓库里
在jar包所在目录打开cmd执行excel第二列的指令(引号记得去掉,写个bat或者直接丢进黑框都行)
执行完指令就能在仓库里看到这堆文件夹
上传到nexus(先装好GIT)
进入仓库
编写文件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}/{} ;
输入代码
./mavenimport.sh -u 账号-p 密码-r http://私库地址/repository/仓库名
比如:./mavenimport.sh -u admin -p 123456 -r http://127.0.0.1:9190/repository/3part
完成!!!!!!