需求
私服搭好了,但没外网代理用不了,只能自己本地仓库传进去
本地需要提前准备好maven,和git(用于执行shell脚本),以及Nexus私服
打开本地maven仓库,例如 D:/Repository,在该目录下创建两个文件,如下
第一个: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}/{} ;
第二个:runGit.sh
[username] 替换为nexus有上传权限的账户名
[password]替换为nexus有上传权限账户密码
[url]替换问Nexus私服仓库路径(登录Nexus私服-Browse-选择对应仓库-URL列点击[copy])
./mavenimport.sh -u [username]-p [password] -r [url]
文件准备完毕,右键-打开一个git-bash窗口,如果打开的非当前仓库路径D:/Repository下,分别运行如下命令
cd d:
#移动到D盘
cd Repository
#移动到Repository目录
./runGit.sh
#启动上传脚本后就可以等待上传了