+++ /dev/null
-#!/bin/bash
-DISTRIBUTION=$1
-VERSION=$(mvn -B -N help:evaluate -Dexpression=project.version 2>/dev/null| grep -v "^\[")
-VALID_DISTROS=("unstable" "wheezy" "squeeze" "production" \
- "production-proposed-updates" "pre-staging" "staging")
-SPECIAL_BRANCHES=("feature/" "hotfix/" "poc/" "integration")
-
-function containsElement () {
- local e
- for e in "${@:2}"; do [[ "$e" = "$1" ]] && return 0; done
- return 1
-}
-
-function startswithElement () {
- local e
- local l
- for e in "${@:2}"; do
- l=${#e} # length of the element
- # test if element equals $1 with the length of element:
- [[ "$e" = "${1:0:$l}" ]] && return 0
- done
- return 1
-}
-
-function cleanup {
- echo cleaning up ...
- # revert changelog changes
- git checkout -- debian/changelog
- # remove files created by debian build
- git clean -fd debian
- echo cleaup done
-}
-
-function validateInput
-{
- APPEND_TO_VERSION=""
-
- if [[ -z "${VERSION}" ]] ; then
- echo "ERROR: Cannot get version from maven using 'mvn -B -N help:evaluate -Dexpression=project.version'"
- mvn -B -N help:evaluate -Dexpression=project.version
- exit 1
- fi
-
- if startswithElement $GIT_BRANCH_NAME "${SPECIAL_BRANCHES[@]}" ; then
- if [ "$GIT_BRANCH_NAME" = "integration" ] ; then
- DISTRIBUTION="dev-integration"
- else
- # set proper DISTRIBUTION for feature branches
- DISTRIBUTION= $(echo "dev-${GIT_BRANCH_NAME}" | tr '/' '-')
- fi
- APPEND_TO_VERSION = "experimental"
- elif ! containsElement $DISTRIBUTION "${VALID_DISTROS[@]}" ; then
- echo "\$DISTRIBUTION is set to $DISTRIBUTION but thats not a valid distribution, which are: $VALID_DISTROS"
- exit 1
- if [ "$DISTRIBUTION" = "unstable" ] || [ "$DISTRIBUTION" = "pre-staging" ] ; then
- APPEND_TO_VERSION = "develop"
- fi
- fi
-
- if [ ! -z "$APPEND_TO_VERSION" ] ; then
- # remove -SNAPSHOT
- VERSION=$(echo $VERSION | sed -s "s#-SNAPSHOT##g")
- BUILD_START=$(date +%Y%m%d%H%M%S)
- VERSION="${VERSION}~${APPEND_TO_VERSION}${BUILD_START}+{BUILD_NUMBER}+g${GIT_COMMIT:0:7}"
- echo "=================================="
- echo $VERSION
- echo "=================================="
- fi
-}
-
-#############
-# MAIN
-#############
-cd $WORKSPACE
-validateInput
-set -e # fail on error
-set -x # echo commands executed
-
-if [ "$GIT_BRANCH_NAME" = "master" ] || [ "${GIT_BRANCH_NAME:0:7}" = "hotfix/" ] ; then
- git-dch -a --ignore-branch --no-full --no-meta --id-length=7 -N $VERSION
- sed -i "0,/UNRELEASED/s//$DISTRIBUTION/" debian/changelog
-else
- # change version in changelog
- git-dch -a --ignore-branch --no-full --no-meta --id-length=7
- # replace first version (enclosed in brackets) with real version
- sed -i "0,/(.*)/s//($VERSION)/" debian/changelog
- # replace first UNRELEASED with $DISTRIBUTION
- sed -i "0,/UNRELEASED/s//$DISTRIBUTION/" debian/changelog
-fi
-
-# build debian package (just binary, no source package)
-dpkg-buildpackage -us -uc -b
-
-# push back to git repo if build from master or hotfix/
-if [ "$GIT_BRANCH_NAME" = "master" ] || [ "${GIT_BRANCH_NAME:0:7}" = "hotfix/" ] ; then
- git add debian/changelog
- git commit -m "Automatic commit by jenkins after build of $BUILD_NUMBER"
- # ~ and : are not valid in git tags, replace them:
- TAG=$(echo $VERSION | tr '~' '_' | tr ':' ',')
- git tag $TAG
- git push origin $GIT_BRANCH_NAME
- git push origin $TAG
-fi
-
-# upload to reprepro
-# TODO: implement
-
-# show the changelog
-dpkg-parsechangelog
-
-set +x
-cleanup
-
-#TODO: remove this debug output
-export
--- /dev/null
+#!/bin/bash
+DISTRIBUTION=$1
+VERSION=$(mvn -B -N help:evaluate -Dexpression=project.version 2>/dev/null| grep -v "^\[")
+VALID_DISTROS=("unstable" "wheezy" "squeeze" "production" \
+ "production-proposed-updates" "pre-staging" "staging")
+SPECIAL_BRANCHES=("feature/" "hotfix/" "poc/" "integration")
+
+function containsElement () {
+ local e
+ for e in "${@:2}"; do [[ "$e" = "$1" ]] && return 0; done
+ return 1
+}
+
+function startswithElement () {
+ local e
+ local l
+ for e in "${@:2}"; do
+ l=${#e} # length of the element
+ # test if element equals $1 with the length of element:
+ [[ "$e" = "${1:0:$l}" ]] && return 0
+ done
+ return 1
+}
+
+function cleanup {
+ echo cleaning up ...
+ # revert changelog changes
+ git checkout -- debian/changelog
+ # remove files created by debian build
+ git clean -fd debian
+ echo cleaup done
+}
+
+function validateInput
+{
+ APPEND_TO_VERSION=""
+
+ if [[ -z "${VERSION}" ]] ; then
+ echo "ERROR: Cannot get version from maven using 'mvn -B -N help:evaluate -Dexpression=project.version'"
+ mvn -B -N help:evaluate -Dexpression=project.version
+ exit 1
+ fi
+
+ if startswithElement $GIT_BRANCH_NAME "${SPECIAL_BRANCHES[@]}" ; then
+ if [ "$GIT_BRANCH_NAME" = "integration" ] ; then
+ DISTRIBUTION="dev-integration"
+ else
+ # set proper DISTRIBUTION for feature branches
+ DISTRIBUTION=$(echo "dev-${GIT_BRANCH_NAME}" | tr '/' '-')
+ fi
+ APPEND_TO_VERSION="experimental"
+ elif ! containsElement $DISTRIBUTION "${VALID_DISTROS[@]}" ; then
+ echo "\$DISTRIBUTION is set to $DISTRIBUTION but thats not a valid distribution, which are: $VALID_DISTROS"
+ exit 1
+ if [ "$DISTRIBUTION" = "unstable" ] || [ "$DISTRIBUTION" = "pre-staging" ] ; then
+ APPEND_TO_VERSION="develop"
+ fi
+ fi
+
+ if [ ! -z "$APPEND_TO_VERSION" ] ; then
+ # remove -SNAPSHOT
+ VERSION=$(echo $VERSION | sed -s "s#-SNAPSHOT##g")
+ BUILD_START=$(date +%Y%m%d%H%M%S)
+ VERSION="${VERSION}~${APPEND_TO_VERSION}${BUILD_START}+{BUILD_NUMBER}+g${GIT_COMMIT:0:7}"
+ echo "=================================="
+ echo $VERSION
+ echo "=================================="
+ fi
+}
+
+#############
+# MAIN
+#############
+cd $WORKSPACE
+validateInput
+set -e # fail on error
+set -x # echo commands executed
+
+if [ "$GIT_BRANCH_NAME" = "master" ] || [ "${GIT_BRANCH_NAME:0:7}" = "hotfix/" ] ; then
+ git-dch -a --ignore-branch --no-full --no-meta --id-length=7 -N $VERSION
+ sed -i "0,/UNRELEASED/s//$DISTRIBUTION/" debian/changelog
+else
+ # change version in changelog
+ git-dch -a --ignore-branch --no-full --no-meta --id-length=7
+ # replace first version (enclosed in brackets) with real version
+ sed -i "0,/(.*)/s//($VERSION)/" debian/changelog
+ # replace first UNRELEASED with $DISTRIBUTION
+ sed -i "0,/UNRELEASED/s//$DISTRIBUTION/" debian/changelog
+fi
+
+# build debian package (just binary, no source package)
+dpkg-buildpackage -us -uc -b
+
+# push back to git repo if build from master or hotfix/
+if [ "$GIT_BRANCH_NAME" = "master" ] || [ "${GIT_BRANCH_NAME:0:7}" = "hotfix/" ] ; then
+ git add debian/changelog
+ git commit -m "Automatic commit by jenkins after build of $BUILD_NUMBER"
+ # ~ and : are not valid in git tags, replace them:
+ TAG=$(echo $VERSION | tr '~' '_' | tr ':' ',')
+ git tag $TAG
+ git push origin $GIT_BRANCH_NAME
+ git push origin $TAG
+fi
+
+# upload to reprepro
+# TODO: implement
+
+# show the changelog
+dpkg-parsechangelog
+
+set +x
+cleanup
+
+#TODO: remove this debug output
+export
--- /dev/null
+#!/bin/bash
+
+function containsElement () {
+ local e
+ for e in "${@:2}"; do [[ "$e" = "$1" ]] && return 0; done
+ return 1
+}
+
+set -e
+
+if [ ${GIT_BRANCH_NAME:0:8} = "feature/" ] ; then
+ if containsElement "merge" "${BUILD_TRIGGERS[@]}" ; then
+ echo "Switching to integration branch..."
+ git checkout integration
+ echo "Trying to fast-forward merge $GIT_BRANCH_NAME..."
+ git merge --no-ff $GIT_BRANCH_NAME
+ fi
+elif [ "$GIT_BRANCH_NAME" = "master" ] || [ "${GIT_BRANCH_NAME:0:7}" = "hotfix/" ] ; then
+ VERSION=$(mvn -B -N help:evaluate -Dexpression=project.version 2>/dev/null| grep -v "^\[")
+ TAG=$(echo $VERSION | tr '~' '_' | tr ':' ',')
+ git tag $TAG -m "Testing whether there is already a tag $TAG..."
+ git tag -d $TAG
+fi