侧边栏壁纸
博主头像
MDZZW博主等级

曾经也是帅哥,如今只是肉多

  • 累计撰写 28 篇文章
  • 累计创建 26 个标签
  • 累计收到 7 条评论

本地仓库所有Jar批量上传到Nexus

MDZZW
2023-03-09 / 0 评论 / 0 点赞 / 885 阅读 / 331 字
温馨提示:
本文最后更新于 2023-03-09,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

需求

迁移Nexus新建一个空的Nexus服务,Nexus 自带的Upload功能一个一个上传jar 太痛苦

创建一个新仓库

  1. 创建Blob Stores
    image-1678328562319
  2. 创建Nexus 代理仓库
    该仓库作用就是当本地仓库不存在某个jar 的时候去远程仓库去拿,也可以不创建该仓库那代码加了新依赖就自己从本地手动上传吧
    image-1678328673920
    image-1678329084341
  3. 创建发行版仓库
    image-1678329375548
    image-1678329469346
  4. 创建快照版仓库
    image-1678329375548
    image-1678329639835
  5. 创建组将所有仓库整合
    image-1678329684107
    image-1678329836791

编辑脚本 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}/{} ;


将脚本放入本地仓库目录

image

使用GitBash执行脚本

这里只需要上传发行版和快照版 就可以了
./mavenimport.sh -u 账号 -p 密码 -r http://Nexus ip:Nexus端口/repository/仓库的名称

最后感谢该博客作者

windows版nexus批量导入jar

0

评论区