]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
- Re-adds tagging feature that was accidentally dropped
authorPascal Giannakakis <pascal.giannakakis@profitbricks.com>
Mon, 23 Jun 2014 17:57:45 +0000 (19:57 +0200)
committerPascal Giannakakis <pascal.giannakakis@profitbricks.com>
Mon, 23 Jun 2014 17:57:45 +0000 (19:57 +0200)
maven_post_build_debian_wrapper.sh

index 4d2dde80a2124612c2772094935d2bae1851537d..c1e2244921781ed7c4c56fa9afc440c8e547cba9 100755 (executable)
@@ -7,16 +7,36 @@
 #
 # this script is run after maven for maven build jobs
 
+function validateSettings {
+    VERSION=$(mvn -B -N help:evaluate -Dexpression=project.version 2>/dev/null| grep -v "^\[" | grep -v "^D" )
+    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
+}
+
 #############
 # MAIN
 #############
 
 cd $WORKSPACE
 
+validateSettings
+
 export
 set -e      # fail on error
 set -x      # echo commands executed
 
+# push back to git repo if build from master or hotfix/
+if [[ "$GIT_BRANCH_NAME" = "master" ]] || [[ "${GIT_BRANCH_NAME:0:7}" = "hotfix/" ]]; then
+    # ~ and : are not valid in git tags, replace them:
+    TAG=$(echo $VERSION | tr '~' '_' | tr ':' ',')
+    git tag $TAG
+    git push origin $TAG
+    figlet "Tagged."
+fi
+
 # 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