將以下兩個腳本放在待上傳的倉庫根目錄下 ,刪除所有lastUpdated文件和_remote.repositories文件后執行
sh upload.sh即可將upload.sh同級目錄及子目錄下所有文件上傳至 upload.sh內指定的遠程倉庫
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 './upload.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}/{} ;
upload.sh
## -u nexus用戶名 -p nexus密碼 -r 遠程倉庫地址
sh mavenimport.sh -u admin -p admin123 -r http://127.9.9.1:8081/repository/bemp-snapshots/
