当前位置:网站首页>Shell常用脚本:Nexus批量上传本地仓库脚本
Shell常用脚本:Nexus批量上传本地仓库脚本
2022-07-31 22:31:00 【嗯嗯**】
文章参考: https://blog.csdn.net/qq_35237533/article/details/125159799
本人有对此脚本有做进一步增强,推荐使用我新写的增强脚本,如使用请到这个链接进行查看【20220727】 https://blog.csdn.net/weixin_39651356/article/details/126007459
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
# 步骤1:优化原作者有些无啥必要的筛选,因为写的必不起作用,特别注意 -path并不是正则,很像mysql的like模糊查询,大量使用到的转义字符压根没啥软用,而且就算是正则语法他写的也是错的
#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}/{} ;
# 下行命令讲解
# 步骤1:当前目录下找出所有是文件非目录类型的文件 - 且排除掉mavenimport.sh文件
# 步骤2:将当前筛选出的文件绝对路径== 前面的 ./ 字符替换成空字符
# 如 ./cn/hutool/hutool-all/5.8.4/hutool-all-5.8.4.jar ==> cn/hutool/hutool-all/5.8.4/hutool-all-5.8.4.jar
# 如 ./cn/hutool/hutool-all/5.8.4/hutool-all-5.8.4.pom ==> cn/hutool/hutool-all/5.8.4/hutool-all-5.8.4.pom
# 步骤3:开始一个一个的上传文件(筛选出有多少行文件绝对路径,则curl则执行多少遍)
# curl -u "$USERNAME:$PASSWORD" -X PUT -v -T cn/hutool/hutool-all/5.8.4/hutool-all-5.8.4.jar ${REPO_URL}/cn/hutool/hutool-all/5.8.4/hutool-all-5.8.4.jar
# curl -u "$USERNAME:$PASSWORD" -X PUT -v -T cn/hutool/hutool-all/5.8.4/hutool-all-5.8.4.pom ${REPO_URL}/cn/hutool/hutool-all/5.8.4/hutool-all-5.8.4.pom
find . -type f -not -path '*mavenimport.sh*' | sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {
} ${REPO_URL}/{
} ;
脚本使用
sh mavenimport.sh -u admin -p admin123 -r http://192.168.19.107:8082/repository/lrc/


上传成功
边栏推荐
- [QNX Hypervisor 2.2用户手册]9.14 set
- Golang must know the Go Mod command
- In Golang go-redis cluster mode, new connections are constantly created, and the problem of decreased efficiency is solved
- How to identify fake reptiles?
- SQL27 View user details of different age groups
- The old music player WinAmp released version 5.9 RC1: migrated to VS 2019, completely rebuilt, compatible with Win11
- BM3 flips the nodes in the linked list in groups of k
- @JsonFormat(pattern="yyyy-MM-dd") time difference problem
- Components of TypeScript
- useragent online lookup
猜你喜欢

Unity - by casting and cloning method dynamic control under various UGUI create and display

21. Support Vector Machine - Introduction to Kernel Functions

The principle of ReentrantLock (to be continued)
不知道该怎么办的同步问题

登录业务实现(单点登录+微信扫码+短信服务)

Redis综述篇:与面试官彻夜长谈Redis缓存、持久化、淘汰机制、哨兵、集群底层原理!...

Go1.18 upgrade function - Fuzz test from scratch in Go language

GateWay implements load balancing

ECCV 2022 Huake & ETH propose OSFormer, the first one-stage Transformer framework for camouflaging instance segmentation!The code is open source!...

flowable workflow all business concepts
随机推荐
Niuke.com brush questions (1)
Structure of the actual combat battalion module eight operations
Verilog implements a divide-by-9 with a duty cycle of 5/18
A high-quality WordPress download site template theme developed abroad
Flex layout in detail
sqlite3 simple operation
如何减少软件设计和实现之间鸿沟
[Open class preview]: Research and application of super-resolution technology in the field of video image quality enhancement
「APIO2010」巡逻 题解
"The core concept of" image classification and target detection in the positive and negative samples and understanding architecture
Commonly used security penetration testing tools (penetration testing tools)
BOW/DOM (top)
BM5 merge k sorted linked lists
Binary tree non-recursive traversal
嵌入式开发没有激情了,正常吗?
A shortcut to search for specific character content in idea
Embedded development has no passion, is it normal?
一款国外开发的高质量WordPress下载站模板主题
Socket Review and I/0 Model
无状态与有状态的区别