场景
私服崩了,上一篇谢了安装nexus的流程, 现在需要本地仓库jar同步到nexus
白话: 把本地jart上传到服务器某一个文件夹, 脚本读取这个文件夹存到私服
编写导入脚本
cd /data/nexus/my_repository
vi maven-import.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 './maven-import\.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}/{} ;
授权脚本文件
chmod +x maven-import.sh
执行脚本
cd /data/nexus/my_repository
./maven-import.sh -u admin -p 123456 -r http://xxx.xxx.xxx.xxx:8081/repository/my-repository/