Skip to content

Instantly share code, notes, and snippets.

@trydofor
Created September 15, 2018 05:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trydofor/21324b9fabb7d6bb61c89449feb3b804 to your computer and use it in GitHub Desktop.
Save trydofor/21324b9fabb7d6bb61c89449feb3b804 to your computer and use it in GitHub Desktop.
deploy local repo to nexus
#!/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