方案1
配置文件内容
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- <localRepository>D:\Java\apache-maven-3.5.4\repository</localRepository> -->
<mirrors>
</mirrors>
<servers>
<server>
<id>deploy-it</id>
<username>jinko_maven</username>
<password>jinko_maven</password>
</server>
<server>
<id>maven-snapshot</id>
<username>jinko_maven</username>
<password>jinko_maven</password>
</server>
</servers>
<profiles>
<profile>
<id>jdk-1.8</id>
<activation>
<!-- 默认激活 -->
<activeByDefault>true</activeByDefault>
<!-- 设置maven默认的 jdk 为 1.8 -->
<jdk>1.8</jdk>
</activation>
<repositories>
<!-- 配置多个仓库,多个同时生效 -->
<repository>
<id>deploy-it</id>
<name>deploy-it</name>
<url>http://xxx.xxx.xx.xx:8081/repository/xxx-it/</url>
</repository>
</repositories>
</profile>
</profiles>
</settings>
上传命令
mvn deploy:deploy-file -s "C:\Users\xxx\.m2\deploy.xml" -DgroupId=groupId -DartifactId=artifactId -Dversion=version -Dpackaging=jar -DrepositoryId=deploy-it -Durl='http://xxx.xxx.xx.xx:8081/repository/xxx-it/' -Dfile=release.jar
方案2
#!/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 |grep -E '*.*$'| sed "s|^\./||" | xargs -I '{}' curl -u "$USERNAME:$PASSWORD" -X PUT -v -T {} ${REPO_URL}/{} ;
## find . -type f |grep -E "*.jar"| sed "s/^.\///"| sed "s/.jar$//"| xargs -I '{}' mvn deploy:deploy-file -s "C:\Users\xxx\.m2\deploy.xml" -Durl='http://ip:port/repository/jk-it/' -DgroupId=com.jinko.oa -DartifactId={} -Dversion=1.0 -Dpackaging=jar -DrepositoryId=deploy-it -Dfile={}.jar;
jar包目录结构
./mavenimport.sh -u admin -p xxxx -r http://xxx.xxx.xxx.xxx:8081/repository/xxx/