Previously every branch push / commit ended up in the same BUILD-SNAPSHOT artefact. In order to avoid potential confusion we now change the pom versions to create issue specific snapshot-builds next to the build-snapshot that is created for the master branch. As an example the version number in SD Commons 1.7.0.BUILD-SNAPSHOT for issue DATACMNS-42 becomes 1.7.0.DATACMNS-42-SNAPSHOT. This is automatically performed by the new-issue-branch.sh script. When one begins to work on a ticket just execute: new-issue-branch.sh DATAMODULE-ISSUENUMBER E.g.: new-issue-branch.sh DATACMNS-42 will create a new branch issue/DATACMNS-42 in SD Commons.
30 lines
1.2 KiB
Bash
Executable File
30 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
||
#
|
||
# This script creates a new local issue branch for the given issue id.
|
||
# Previous changes are stashed before the issue branch is created and are reapplied after branch creation.
|
||
#
|
||
# executing new-issue-branch.sh DATACMNS-42
|
||
# will create a new (local) branch issue/DATACMNS-42
|
||
|
||
TICKET_ID=${1:?"TICKET_ID Parameter is missing!"}
|
||
OLD_VERSION_TMP=$(mvn -o org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version | grep -Ev '^\[.*')
|
||
|
||
OLD_POM_VERSION=${OLD_VERSION_TMP:?"Could not extract current project version from pom.xml"}
|
||
|
||
# Replaces BUILD in BUILD-SNAPSHOT with the given TICKET_ID
|
||
NEW_POM_VERSION=${OLD_POM_VERSION/"BUILD"/$TICKET_ID}
|
||
ISSUE_BRANCH="issue/$TICKET_ID"
|
||
|
||
echo "Creating feature branch $TICKET_ID: $OLD_POM_VERSION -> $NEW_POM_VERSION"
|
||
|
||
echo "Stashing potential intermediate changes..." && git stash\
|
||
&& git checkout -b $ISSUE_BRANCH\
|
||
&& mvn -o -q versions:set -DgenerateBackupPoms=false -DnewVersion=$NEW_POM_VERSION\
|
||
&& ( \
|
||
(\
|
||
git commit -am "$TICKET_ID - Prepare branch"\
|
||
&& echo "Created feature branch: $ISSUE_BRANCH"\
|
||
&& echo "Reapplying potentially stashed changes... " && git stash pop)\
|
||
|| echo "Something went wrong!")
|
||
|