Created
September 15, 2018 05:25
-
-
Save trydofor/21324b9fabb7d6bb61c89449feb3b804 to your computer and use it in GitHub Desktop.
deploy local repo to nexus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#https://support.sonatype.com/hc/en-us/articles/115006744008 | |
repoId="nexus-jiayu" | |
repoUrl="http://maven.jiayuinc.com/repository/devops/" | |
tempDir="/tmp/" | |
function deploy_pom(){ | |
pom=$1 | |
ext=$(grep packaging $pom | sed -E 's/^.*>(.*)<.*$/\1/g') | |
if [ "$ext" == "" ]; then | |
ext="jar" | |
fi | |
art=${pom%.*}.${ext} | |
cmdCp="/bin/cp -f" | |
cmdRm="/bin/rm -f" | |
distPom=$tempDir/$(basename $pom) | |
distArt=$tempDir/$(basename $art) | |
# can not upload at local repo dir. | |
$cmdCp $pom $distPom | |
$cmdCp $art $distArt | |
mvn deploy:deploy-file \ | |
-DgeneratePom=false \ | |
-DrepositoryId=$repoId \ | |
-Durl=$repoUrl \ | |
-DpomFile=$distPom \ | |
-Dfile=$distArt | |
$cmdRm $distPom | |
$cmdRm $distArt | |
} | |
if [ -f "$1" ]; then | |
deploy_pom $1 | |
exit | |
fi | |
workDir="." | |
if [ -d "$1" ]; then | |
workDir=$1 | |
fi | |
find $workDir -type f -name "*.pom" | while read pom; do | |
deploy_pom $pom | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment