Site Overlay

windosw环境本地Maven仓库上传Nexus私服

需求

私服搭好了,但没外网代理用不了,只能自己本地仓库传进去

本地需要提前准备好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
#启动上传脚本后就可以等待上传了

发表回复

您的电子邮箱地址不会被公开。

A beliving heart is your magic My heart
欢迎来到Diuut的个人博客,这里是我的一些零零碎碎的知识汇总,希望有能帮到你的内容。 | 蜀ICP备2021011635号-1 | Copyright © 2025 Diuut. All Rights Reserved.