60-010-020-使用-Nexus3批量上传jar包

1.美图

在这里插入图片描述# 2.概述
因为要上传我的所有仓库的包,希望nexus中已有的包,我不覆盖,没有的添加。所以想批量上传jar。

3.方案1-脚本批量上传

PS:nexus3.x版本只能通过脚本上传

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-e204HRFp-1585563810499)(00-nexus-image/image-20200330151629404.png)]

3.1 批量放入jar

  • 在mac目录下,新建一个文件夹repo,批量放入我们需要的本地库文件夹,并对文件夹授权
(base) lcc@lcc nexus-3.22.0-02$ mkdir repo2
(base) lcc@lcc nexus-3.22.0-02$ chmod -R 777 repo2

创建脚本

(base) lcc@lcc nexus-3.22.0-02$ vi  maven_local_to_nexus.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}/{} ;


赋予脚本可执行权限,建立链接

./maven_local_to_nexus.sh  -u admin -p 123456 -r http://localhost:8081/repository/maven-lcc

但是这样上传后是一个默认全放到system下了。

执行后效果

< HTTP/1.1 201 Created
< Date: Mon, 30 Mar 2020 07:24:03 GMT
< Server: Nexus/3.22.0-02 (OSS)
< X-Content-Type-Options: nosniff
< Content-Security-Policy: sandbox allow-forms allow-modals allow-popups allow-presentation allow-scripts allow-top-navigation
< X-XSS-Protection: 1; mode=block
< Content-Length: 0
<
* Connection #0 to host localhost left intact
*   Trying ::1:8081...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 8081 failed: Connection refused
*   Trying 127.0.0.1:8081...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8081 (#0)
* Server auth using Basic with user 'admin'
> PUT /repository/maven-lcc/snapshots/system/org/sonatype/nexus/nexus-oss-edition/3.22.0-02/nexus-oss-edition-3.22.0-02-features.xml HTTP/1.1
> Host: localhost:8081
> Authorization: Basic YWRtaW46MTIzNDU2
> User-Agent: curl/7.68.0
> Accept: */*
> Content-Length: 469
> Expect: 100-continue
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 100 Continue
* We are completely uploaded and fine

界面如图

在这里插入图片描述

4.方案2-直接拷贝(nexus 2)

把本地仓库中的jar包拷贝到私服central(我的路径为D:\nexus\nexus-2.14.8-01-bundle\sonatype-work\nexus\storage\central)中,

在这里插入图片描述
然后更新索引,不更新索引无效

在这里插入图片描述

参考:https://blog.csdn.net/libusi001/article/details/99593832

发布了1156 篇原创文章 · 获赞 454 · 访问量 145万+

猜你喜欢

转载自blog.csdn.net/qq_21383435/article/details/105205403
今日推荐