Skip to content

Instantly share code, notes, and snippets.

@dwelch2344
Created March 24, 2016 23:51
Show Gist options
  • Save dwelch2344/49e3c38a539485785d9d to your computer and use it in GitHub Desktop.
Save dwelch2344/49e3c38a539485785d9d to your computer and use it in GitHub Desktop.
This jenkins script looks for a ENV VAR (parameterized via Build Params) defined as *RELEASE*, which if != "No" will Swap the traditional X.Y.Z[-IDENTIFIER] version for X.Y.Zb[BUILD_NUMBER][IDENTIFIER] (with IDENTIFIER being determined based on whether RELEASE is Snapshot or Release)
#!/bin/bash
if [[ "$RELEASE" != "No" ]]; then
if [[ "$RELEASE" == "Release" ]]; then
BUILD_SUFFIX=".RELEASE"
elif [[ "$RELEASE" == "Snapshot" ]]; then
BUILD_SUFFIX="-SNAPSHOT"
fi
echo "Swapping version for X.X.${BUILD_NUMBER}${BUILD_SUFFIX}"
sed -i -e "1,/<version>\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*<\/version>/s/<version>\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*<\/version>/<version>\1.\2.\3b${BUILD_NUMBER}${BUILD_SUFFIX}<\/version>/" pom.xml
else
echo "Not swapping version"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment