Last active
November 16, 2019 05:31
-
-
Save lielran/9385790 to your computer and use it in GitHub Desktop.
Jenkins get Maven Version and save it to properties file
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
echo "######Getting Dev Version From Pom##########" > /dev/null 2>&1 | |
SNAPSHOT="-SNAPSHOT"; | |
DEV_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dq -Dexpression=project.version | grep -v '\['); | |
export RELEASE_VERSION="$(echo $DEV_VERSION | sed "s@$SNAPSHOT@@").$BUILD_NUMBER"; | |
echo "#############################################" > /dev/null 2>&1 | |
echo "###Development Version is : $DEV_VERSION ###" > /dev/null 2>&1 | |
echo "###Release Version is : $RELEASE_VERSION ###" > /dev/null 2>&1 | |
echo "#############################################" > /dev/null 2>&1 | |
echo DEV_VERSION =$(echo $DEV_VERSION) > propsfile | |
echo RELEASE_VERSION =$(echo $RELEASE_VERSION ) > propsfile |
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
SNAPSHOT="-SNAPSHOT"; | |
DEV_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dq -Dexpression=project.version | grep -Ev '(^\[|Download\w+:)' ); | |
echo "######Current Version is: $DEV_VERSION ##########" > /dev/null 2>&1 | |
substring=$SNAPSHOT | |
if [ "${DEV_VERSION/$substring}" = "$DEV_VERSION" ] ; then | |
echo "${substring} is not in ${DEV_VERSION}" | |
echo "this is release version --> bump the version" | |
export RELEASE_VERSION="$(echo ${DEV_VERSION%.*}).$BUILD_NUMBER"; | |
else | |
echo "${substring} was found in ${DEV_VERSION}" | |
export RELEASE_VERSION="$(echo $DEV_VERSION | sed "s@$SNAPSHOT@@").$BUILD_NUMBER"; | |
fi | |
echo "#############################################" > /dev/null 2>&1 | |
echo "###Development Version is : $DEV_VERSION ###" > /dev/null 2>&1 | |
echo "###Release Version is : $RELEASE_VERSION ###" > /dev/null 2>&1 | |
echo "#############################################" > /dev/null 2>&1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the scripts.
Add "-B" with mvn command will help on first run the scripts.
Because mvn will download jar files for first run and make grep command return wrong value.