From: Holger Levsen Date: Thu, 25 Jul 2013 13:57:00 +0000 (+0200) Subject: derive suite from jenkins job. cleanup + restructure code X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=f50ac3e61d1648b1fb4e7627d98b8f2252153557;p=profitbricks%2Fjenkins-build-scripts.git derive suite from jenkins job. cleanup + restructure code --- diff --git a/maven_post_build_debian_wrapper.sh b/maven_post_build_debian_wrapper.sh index 2f17db5..90c4fb8 100755 --- a/maven_post_build_debian_wrapper.sh +++ b/maven_post_build_debian_wrapper.sh @@ -9,18 +9,10 @@ # it updates debian/changelog, builds the debian package(s) and uploads to our repo. # -DISTRIBUTION=$1 # we cannot derive the distro from the branch as there is wheezy+squeeze, so this has to come from the job definition +SUITE=$1 # this has to be either squeeze or wheezy currently 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") -REPO=pb-squeeze - -function containsElement () { - local e - for e in "${@:2}"; do [[ "$e" = "$1" ]] && return 0; done - return 1 -} +FEATURE_BRANCHES=("feature/" "poc/" "integration") +REPO=pb-${SUITE} function startswithElement () { local e @@ -42,7 +34,7 @@ function cleanup { echo cleaup done } -function validateInput +function validateSettings { APPEND_TO_VERSION="" @@ -52,21 +44,20 @@ function validateInput exit 1 fi - if startswithElement $GIT_BRANCH_NAME "${SPECIAL_BRANCHES[@]}" ; then + if startswithElement $GIT_BRANCH_NAME "${FEATURE_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 - REPO="dev-squeeze" + REPO="dev-${SUITE}" APPEND_TO_VERSION="experimental" - elif ! containsElement $DISTRIBUTION "${VALID_DISTROS[@]}" || [ -z "$DISTRIBUTION" ] ; 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 + elif [ "$GIT_BRANCH_NAME" = "master" ] || [ ${GIT_BRANCH_NAME:0:7} = "hotfix/" ] + DISTRIBUTION="production-proposed-updates" + else + DISTRIBUTION="unstable" + APPEND_TO_VERSION="develop" fi if [ ! -z "$APPEND_TO_VERSION" ] ; then @@ -74,19 +65,20 @@ function validateInput 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}" - SOURCE=$(dpkg-parsechangelog 2>/dev/null|grep ^Source:|cut -d " " -f2) # get the name of the source package - echo "Ahout to start to build the debian packages:" - echo "============================================" - echo "$SOURCE $VERSION" - echo "============================================" fi + + SOURCE=$(dpkg-parsechangelog 2>/dev/null|grep ^Source:|cut -d " " -f2) # get the name of the source package + echo "Ahout to start to build the debian packages:" + echo "============================================" + echo "$SOURCE $VERSION" + echo "============================================" } ############# # MAIN ############# cd $WORKSPACE -validateInput +validateSettings export set -e # fail on error set -x # echo commands executed