From: Holger Levsen Date: Wed, 24 Jul 2013 11:50:39 +0000 (+0200) Subject: add check for valid distros and git_branches X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=cd593859b2aae9e87852f511e2163d49dafab06d;p=profitbricks%2Fjenkins-build-scripts.git add check for valid distros and git_branches --- diff --git a/debian_wrap_maven_results.sh b/debian_wrap_maven_results.sh index 3f99fd1..1ac6cf7 100755 --- a/debian_wrap_maven_results.sh +++ b/debian_wrap_maven_results.sh @@ -2,11 +2,25 @@ DISTRIBUTION=$1 VERSION=$(mvn -B -N help:evaluate -Dexpression=project.version | grep -v "^\[") SCRIPTNAME=${0##*/} -VALID_DISTROS=("unstable" "wheezy" "squeeze") +VALID_DISTROS=("unstable" "wheezy" "squeeze" "production" \ + "production-proposed-updates" "pre-staging" "staging" "experimental") +SPECIAL_BRANCHES=("feature/" "hotfix/" "poc/") function containsElement () { local e - for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done + 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 } @@ -21,6 +35,9 @@ function cleanup { function validateInput { + if startswithElement $GIT_BRANCH_NAME "${SPECIAL_BRANCHES[@]}" ; then + DISTRIBUTION="experimental" + fi if ! containsElement $DISTRIBUTION "${VALID_DISTROS[@]}" ; then echo "\$DISTRIBUTION is set to $DISTRIBUTION but thats not a valid distribution, which are: $VALID_DISTROS" @@ -53,11 +70,11 @@ set -e # fail on error set -x # echo commands executed # change version in changelog -git-dch -a --ignore-branch --new-version=${VERSION} +git-dch -a --ignore-branch # we now what we're doing and we don't want an editor.…. -echo | EDITOR=true dch -D ${DISTRIBUTION} -r --no-force-save-on-release -b +echo | EDITOR=true dch -D ${DISTRIBUTION} --newversion ${VERSION} --no-force-save-on-release --force-distribution --force-bad-version -#build debian package (just binary, no sources) +# build debian package (just binary, no source package) dpkg-buildpackage -us -uc -b # push back to git repo