下载
只需要更换仓库名称:http://32.1.0.x:8081/service/rest/repository/browse/maven-snapshot/
1
| wget -m -r -e robots=off -A jar,pom,html -U mozilla http://32.1.0.x:8081/service/rest/repository/browse/maven-snapshot/
|
上传
脚本:
1 2 3 4 5 6 7 8 9
| #!/bin/bash USERNAME="$1" PASSWORD="$2" REPO_URL="$3" echo 'USERNAME' $USERNAME echo 'password' $PASSWORD echo 'REPO_URL' $REPO_URL find . -type f -not -path './mavenimport\.sh*' -not -path './index\.html*' -not -path '*/\.*' -not -path '*/\^archetype\-catalog\.xml*' -not -path '*/\^maven\-metadata\-local*\.xml' -not -path '*/\^maven\-metadata\-deployment*\.xml' | sed "s|^\./||" | xargs -I '{}' curl -v -u $USERNAME:$PASSWORD --upload-file {} ${REPO_URL}/{} ;
|
执行
1
| ./mavenimport.sh admin admin http://nexus/repository/maven/
|
原文
附
url
上传包到nexus
1
| curl -u "$USERNAME:$PASSWORD" -X PUT -v -T localfile ${REPO_URL}/filename
|
官方api
官方
1 2 3
| curl -v -u admin:admin123 -X POST 'http://localhost:8081/service/rest/v1/components?repository=maven-releases' -F maven2.groupId=com.google.guava -F maven2.artifactId=guava -F maven2.version=24.0-jre -F maven2.asset1=@guava-24.0-jre.jar -F maven2.asset1.extension=jar -F maven2.asset2=@guava-24.0-jre-sources.jar -F maven2.asset2.classifier=sources -F maven2.asset2.extension=jar
curl -v -u admin:admin123 -F "maven2.generate-pom=false" -F "maven2.asset1=@/absolute/path/to/the/local/file/pom.xml" -F "maven2.asset1.extension=pom" -F "maven2.asset2=@/absolute/path/to/the/local/file/product-1.0.0.jar;type=application/java-archive" -F "maven2.asset2.extension=jar" "http://localhost:8081/service/rest/v1/components?repository=maven-releases"
|
另一个批量脚本
1 2 3 4 5 6 7 8 9 10 11 12 13
| #!/bin/bash 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 -v -u "$USERNAME:$PASSWORD" --upload-file {} ${REPO_URL}/{} ;
|
执行
1
| ./mavenimport.sh -u admin -p admin -r http://nexus/repository/maven/
|
批量下载NPM
1
| wget -m -r -e robots=off -A jar,pom,html,tgz -U mozilla http://32.1.0.x:8081/service/rest/repository/browse/maven-snapshot/
|
上传NPM
包
1
| curl -v -u admin:admin -X POST "http://32.1.0.x:8081/service/rest/v1/components?repository=npm-skytech" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "npm.asset=@cordova-icon-splash/-/cordova-icon-splash-0.0.1.tgz;type=application/x-compressed"
|
批量下载 NPM
包
脚本 npmimport.sh
1 2 3 4 5 6 7 8 9 10 11
| #!/bin/bash USERNAME="$1" PASSWORD="$2" NEXUS_URL="$3" REPONAME="$4" echo 'USERNAME' $USERNAME echo 'password' $PASSWORD echo 'NEXUS_URL' $NEXUS_URL echo 'REPONAME' $REPONAME
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 -v -u "$USERNAME:$PASSWORD" -X POST "$NEXUS_URL/service/rest/v1/components?repository=$REPONAME" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "npm.asset=@{};type=application/x-compressed" ;
|
执行
1
| ./npmimport.sh admin admin http://32.1.0.x:8081 npm-hosts
|
后台wget
1 2
| wget -b while :;do ps -ef|grep wget ;sleep 1 ;done
|
本文地址: https://github.com/maxzhao-it/blog/post/7c1db227/