0
点赞
收藏
分享

微信扫一扫

Linux 批量上传 jar 包到 Nexus

君之言之 2022-02-15 阅读 58
  1. 新建 maven 宿主仓库:maven2 (hosted)
  2. 新建脚本:mavenimport.sh
    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}/{} ;
    
  3. 授权
    chmod +x mavenimport.sh
    
  4. 运行上传,mavenimport.sh 脚本需要放在上传maven仓库的根目录,如图所示:
    drwxr-xr-x  3 root root  19 2月  14 22:50 antlr
    drwxr-xr-x  3 root root  30 2月  14 22:50 avalon-framework
    drwxr-xr-x  3 root root  38 2月  14 22:47 backport-util-concurrent
    drwxr-xr-x  3 root root  25 2月  14 22:47 classworlds
    drwxr-xr-x  3 root root  17 2月  14 22:47 cn
    drwxr-xr-x  3 root root  20 2月  14 22:47 com
    drwxr-xr-x  3 root root  31 2月  14 22:50 commons-beanutils
    drwxr-xr-x  3 root root  27 2月  14 22:50 commons-chain
    drwxr-xr-x  3 root root  25 2月  14 22:47 commons-cli
    drwxr-xr-x  3 root root  27 2月  14 22:47 commons-codec
    drwxr-xr-x  3 root root  33 2月  14 22:50 commons-collections
    drwxr-xr-x  3 root root  30 2月  14 22:50 commons-digester
    drwxr-xr-x  3 root root  24 2月  14 22:50 commons-io
    drwxr-xr-x  3 root root  26 2月  14 22:47 commons-lang
    drwxr-xr-x  4 root root  56 2月  14 22:50 commons-logging
    drwxr-xr-x  3 root root  31 2月  14 22:50 commons-validator
    drwxr-xr-x  3 root root  19 2月  14 22:50 dom4j
    drwxr-xr-x  3 root root  21 2月  14 22:50 javax
    drwxr-xr-x  3 root root  19 2月  14 22:47 junit
    drwxr-xr-x  3 root root  19 2月  14 22:49 log4j
    drwxr-xr-x  3 root root  20 2月  14 22:50 logkit
    -rwxr-xr-x  1 root root 449 2月  15 21:55 mavenimport.sh
    drwxr-xr-x 11 root root 138 2月  14 22:50 org
    drwxr-xr-x  3 root root  17 2月  14 22:50 oro
    drwxr-xr-x  3 root root  20 2月  14 22:50 sslext
    drwxr-xr-x  3 root root  24 2月  14 22:50 xerces
    drwxr-xr-x  3 root root  22 2月  14 22:50 xml-apis
    
    ./mavenimport.sh  -u 用户名 -p 密码 -r 宿主仓库地址
    
举报

相关推荐

0 条评论