Skip to content

Instantly share code, notes, and snippets.

@wybczu
Last active December 28, 2015 06:29
Show Gist options
  • Save wybczu/7457365 to your computer and use it in GitHub Desktop.
Save wybczu/7457365 to your computer and use it in GitHub Desktop.
#!/bin/bash
ARTIFACTORY_URL="https://artifactory.example.com/artifactory"
ARTIFACTORY_REPO="ext-release-local"
MVN_USERNAME="maven"
MVN_PASSWORD="password"
[[ -z $DEBUG ]] || set -x
umask 0077
if [ $# -ne 4 ]; then
echo "usage: $( basename "$0" ) groupId artifactId version filename"
exit 1
fi
GROUP_ID="$1"
ARTIFACT_ID="$2"
VERSION="$3"
FILE="$4"
PACKAGING="${5:-jar}"
TEMP_SETTINGS="$( mktemp --suffix=.xml )"
trap 'rm -rf ${TEMP_SETTINGS}; exit' EXIT INT TERM
cat <<EOF > "${TEMP_SETTINGS}"
<?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">
<servers>
<server>
<id>${ARTIFACTORY_REPO}</id>
<username>${MVN_USERNAME}</username>
<password>${MVN_PASSWORD}</password>
</server>
</servers>
</settings>
EOF
mvn -e -s "${TEMP_SETTINGS}" deploy:deploy-file \
-Dpackaging="${PACKAGING}" \
-DrepositoryId="${ARTIFACTORY_REPO}" \
-Durl="${ARTIFACTORY_URL}/${ARTIFACTORY_REPO}" \
-DgroupId="${GROUP_ID}" \
-DartifactId="${ARTIFACT_ID}" \
-Dversion="${VERSION}" \
-Dfile="${FILE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment