]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
replace test ([ expression ]) with bash internal [[ expression ]]
authorTobias von der Krone <tobias.vonderkrone@profitbricks.com>
Mon, 29 Jul 2013 07:25:51 +0000 (09:25 +0200)
committerTobias von der Krone <tobias.vonderkrone@profitbricks.com>
Mon, 29 Jul 2013 07:25:51 +0000 (09:25 +0200)
maven_post_build_debian_wrapper.sh

index 62bab2ed407052547fa1c127aab8c609917dda4a..9c2f2964c544ac7fc10f0e69330fed143cd730fc 100755 (executable)
@@ -27,16 +27,16 @@ function validateSettings {
         exit 1
     fi
 
-    if [ "$GIT_BRANCH_NAME" = "integration" ] || [ ${GIT_BRANCH_NAME:0:8} = "feature/" ] || [ ${GIT_BRANCH_NAME:0:3} = "poc/" ] || [ ${GIT_BRANCH_NAME:0:7} = "bugfix/" ]; then
+    if [[ "$GIT_BRANCH_NAME" = "integration" ]] || [[ ${GIT_BRANCH_NAME:0:8} = "feature/" ]] || [[ ${GIT_BRANCH_NAME:0:3} = "poc/" ]] || [[ ${GIT_BRANCH_NAME:0:7} = "bugfix/" ]]; then
         APPEND_TO_VERSION="experimental"
         REPO="dev-${SUITE}"
-        if [ "$GIT_BRANCH_NAME" = "integration" ]; 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
-    elif [ "$GIT_BRANCH_NAME" = "master" ] || [ ${GIT_BRANCH_NAME:0:7} = "hotfix/" ]; then
+    elif [[ "$GIT_BRANCH_NAME" = "master" ]] || [[ ${GIT_BRANCH_NAME:0:7} = "hotfix/" ]]; then
         APPEND_TO_VERSION=""
         DISTRIBUTION="production-proposed-updates"
     else
@@ -44,7 +44,7 @@ function validateSettings {
         APPEND_TO_VERSION="develop"
     fi
 
-    if [ ! -z "$APPEND_TO_VERSION" ]; then
+    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)
@@ -74,7 +74,7 @@ set -e      # fail on error
 set -x      # echo commands executed
 
 # write correct debian/changelog
-if [ "$GIT_BRANCH_NAME" = "master" ] || [ "${GIT_BRANCH_NAME:0:7}" = "hotfix/" ]; then
+if [[ "$GIT_BRANCH_NAME" = "master" ]] || [[ "${GIT_BRANCH_NAME:0:7}" = "hotfix/" ]]; then
     # generate debian/changelog entries since the last upload
     git-dch  -a --ignore-branch --no-full --no-meta --id-length=7 -N $VERSION
     # make sure distribution in changelog is set correctly
@@ -93,7 +93,7 @@ else
 fi
 # check that we replaced things correctly...
 D=$(dpkg-parsechangelog 2>/dev/null|grep ^Distribution:|cut -d " " -f2)
-if [ "$D" != "$DISTRIBUTION" ]; then
+if [[ "$D" != "$DISTRIBUTION" ]]; then
     figlet "Wrong distribution!"
     dpkg-parsechangelog
     exit 1
@@ -115,7 +115,7 @@ dcmd rm $CHANGES_FILE
 cd $WORKSPACE
 
 # push back to git repo if build from master or hotfix/
-if [ "$GIT_BRANCH_NAME" = "master" ] || [ "${GIT_BRANCH_NAME:0:7}" = "hotfix/" ]; then
+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:
@@ -133,8 +133,8 @@ dpkg-parsechangelog
 cleanup
 
 # push back integration branch if we merged a feature branch
-if [ ${GIT_BRANCH_NAME:0:8} = "feature/" ] || [ ${GIT_BRANCH_NAME:0:7} = "bugfix/" ]; then
-        if [[ "$BUILD_TRIGGERS" == *"merge"* ]]; then
+if [[ ${GIT_BRANCH_NAME:0:8} = "feature/" ]] || [[ ${GIT_BRANCH_NAME:0:7} = "bugfix/" ]]; then
+        if [[ "$BUILD_TRIGGERS" = *"merge"* ]]; then
         git push origin integration
         figlet "Pushed to integration."
         git checkout origin/$GIT_BRANCH_NAME -b $GIT_BRANCH_NAME