Skip to content

Instantly share code, notes, and snippets.

@matir91 matir91/snapshot_build.sh
Last active Apr 22, 2019

Embed
What would you like to do?
SNAPSHOT Beta release using jenkins
#!/bin/bash
echo "Current branch: $GIT_BRANCH"
MAIN_SNAPSHOT_BRANCH="origin/develop"
GRADLE_FILE="app/build.gradle"
CURRENT_COMMIT_HASH=$(git rev-parse --short HEAD)
IS_BETA_SNAPSHOT_BUILD=false
if [[ $GIT_BRANCH == $MAIN_SNAPSHOT_BRANCH ]] ; then # Cheks if this build is a beta release
IS_BETA_SNAPSHOT_BUILD=true; # Set that the build is a beta snapshot release
TESTER_GROUP='testers' # Set the beta notification group
# Update version name
VERSION_NAME=$(sed -n -e "s/\s*versionName\s*[\"\']\(.*\)[\"\']\s*/\1/p" $GRADLE_FILE)
NEXT_VERSION_NAME="$VERSION_NAME-$CURRENT_COMMIT_HASH"
sed -i -e "s/\(\s*versionName\s*[\"\']\).*\([\"\']\s*\)/\1$NEXT_VERSION_NAME\2/" $GRADLE_FILE
# Create the release notes
git log --pretty=format:"$NEXT_VERSION_NAME: - %s%n%n" -n 1 > release_notes.txt
git log --pretty=format:"Author: %an <%ae>%n%B" -n 1 >> release_notes.txt
echo -e "\n\nLast 10 changes\n" >> release_notes.txt
git log --pretty=format:"• %s (%an - %ci)" HEAD~11..HEAD^ >> release_notes.txt
fi
echo "TESTER_GROUP=$TESTER_GROUP" > build.properties # Tester beta group to be notified
echo "IS_BETA_SNAPSHOT_BUILD=$IS_BETA_BUILD" >> build.properties # Property that check if it's a SNAPSHOT build.
echo "Property file: "
cat build.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.