]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
test for existing tag early and fail early, so that people dont waste their time...
authorHolger Levsen <holger@layer-acht.org>
Fri, 14 Dec 2012 17:00:37 +0000 (18:00 +0100)
committerHolger Levsen <holger@layer-acht.org>
Fri, 14 Dec 2012 17:00:37 +0000 (18:00 +0100)
debian_build.py

index a026b4df3d577c2c7ad0057fe2421d77e0568bce..3aa3e79554384a7551dda2d55f6f62e3634b0842 100755 (executable)
@@ -465,6 +465,27 @@ if __name__ == '__main__':
         if line_counter <= 2:
             print('debian/changelog: %s' %(line.strip()))
 
+    # let's test if we can tag this build, so we can fail early if we cannot tag it later
+    if GIT_BRANCH_NAME == 'master' or GIT_BRANCH_NAME.startswith('hotfix/'):
+        logger.debug('version: %s' %(version))
+        # replace valid debian version chars that are invalid for git tagging
+        version_tag = version.replace('~','_')
+        version_tag = version_tag.replace(':',',')
+        logger.debug('version_tag: %s' %(version_tag))
+        cmd = ['/usr/bin/git', 'tag', version_tag]
+        try:
+            subprocess.check_call(cmd)
+        except:
+            logger.error('Could not tag repository with "%s".' % version_tag)
+            exit_error()
+        cmd = ['/usr/bin/git', 'tag', '-d', version_tag]
+        try:
+            subprocess.check_call(cmd)
+        except:
+            logger.error('Could not delete tag "%s" from repository.' % version_tag)
+            exit_error()
+        logger.info('Tagged as "%s" woks, tag does not exist yet.' % version_tag)
+
     # set pb_suite which GitBuildPackage() will turn into PB_SUITE
     # if we wrote a changelog entry, use that one
     if GIT_BRANCH_NAME.startswith('feature/') or GIT_BRANCH_NAME.startswith('poc/') or GIT_BRANCH_NAME.startswith('bugfix/') or GIT_BRANCH_NAME == 'develop' or GIT_BRANCH_NAME == 'pre-staging' or GIT_BRANCH_NAME.startswith('release/'):