]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
commit debian/changelog if applicable and set correct distro for feature branches
authorHolger Levsen <holger@layer-acht.org>
Wed, 24 Jul 2013 12:21:21 +0000 (14:21 +0200)
committerHolger Levsen <holger@layer-acht.org>
Wed, 24 Jul 2013 12:21:21 +0000 (14:21 +0200)
debian_wrap_maven_results.sh

index 1ac6cf772383541ac1428185f2fb82c214251508..d1b72969c6ca39301f57193398b2a2826ed9d419 100755 (executable)
@@ -1,10 +1,9 @@
 #!/bin/bash
 DISTRIBUTION=$1
 VERSION=$(mvn -B -N help:evaluate -Dexpression=project.version | grep -v "^\[") 
-SCRIPTNAME=${0##*/}
 VALID_DISTROS=("unstable" "wheezy" "squeeze" "production"  \
                "production-proposed-updates" "pre-staging" "staging" "experimental")
-SPECIAL_BRANCHES=("feature/" "hotfix/" "poc/")
+SPECIAL_BRANCHES=("feature/" "hotfix/" "poc/" "integration")
 
 function containsElement () {
   local e
@@ -15,8 +14,7 @@ function containsElement () {
 function startswithElement () {
   local e
   local l
-  for e in "${@:2}";
-        do
+  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
@@ -36,7 +34,11 @@ function cleanup {
 function validateInput
 {
     if startswithElement $GIT_BRANCH_NAME "${SPECIAL_BRANCHES[@]}" ; then
-       DISTRIBUTION="experimental"
+       if [ "$GIT_BRANCH_NAME" = "integration" ] ; then
+               DISTRIBUTION="unstable"
+       else
+               DISTRIBUTION="experimental"
+       if
     fi
 
     if ! containsElement $DISTRIBUTION "${VALID_DISTROS[@]}" ; then
@@ -45,15 +47,15 @@ function validateInput
     fi
 
     if [ "$DISTRIBUTION" = "experimental" ] ; then
-       # TODO
-       echo TODO set DISTRIBUTION correctly
+       # set proper DISTRIBUTION for feature branches
+       DISTRIBUTION= $(echo "dev-${GIT_BRANCH_NAME}" | tr '/' '-')
     fi
 
-    if [[ -z "${VERSION}" ]]
-    then
+    if [[ -z "${VERSION}" ]] ; then
         echo "Need to specify version"
         exit 1
     fi
+
     # TODO: we need to do better
     VERSION=$(echo $VERSION | sed -s "s#SNAP#0SNAP#g")
     echo "=================================="
@@ -77,11 +79,12 @@ echo | EDITOR=true dch -D ${DISTRIBUTION} --newversion ${VERSION} --no-force-sav
 # build debian package (just binary, no source package)
 dpkg-buildpackage -us -uc -b
 
-# push back to git repo
-if [ "$GIT_BRANCH_NAME" = "master" ] ; then
-       # TODO: git commit
+# 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"
        # TODO: git tag
-       # TODO: git push
+       git push origin $GIT_BRANCH_NAME
 fi
 
 # upload to reprepro