Skip to content

Instantly share code, notes, and snippets.

@skempken
Created November 12, 2014 14:55
Show Gist options
  • Save skempken/58fb4ab2751299adc390 to your computer and use it in GitHub Desktop.
Save skempken/58fb4ab2751299adc390 to your computer and use it in GitHub Desktop.
Fix Build Number with Maven
# update version number - get current version and replace "SNAPSHOT" with BUILD_NUMBER
# Download plugins first
mvn -s $MVN_SETTINGS org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version
# Determine current number in offline mode
CURRENT_SNAPSHOT_VERSION=`mvn -o -s $MVN_SETTINGS org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -v '\['`
echo CURRENT_SNAPSHOT_VERSION is: $CURRENT_SNAPSHOT_VERSION
BUILD_SNAPSHOT_VERSION=`echo $CURRENT_SNAPSHOT_VERSION | sed "s/SNAPSHOT/$BUILD_NUMBER/g"`
echo BUILD_SNAPSHOT_VERSION is: $BUILD_SNAPSHOT_VERSION
mvn -s $MVN_SETTINGS versions:set -DnewVersion=$BUILD_SNAPSHOT_VERSION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment