]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
first tag, then upload. replace ~ in version with _ for tagging. fail if version...
authorHolger Levsen <holger@layer-acht.org>
Thu, 15 Mar 2012 13:17:26 +0000 (14:17 +0100)
committerHolger Levsen <holger@layer-acht.org>
Thu, 15 Mar 2012 13:22:38 +0000 (14:22 +0100)
debian_build.py

index 4a23adffd18dbdbf6a519688ff62c45f3d1b25c4..d2ac1105588acc77d36a24af278dfc0689d86f29 100755 (executable)
@@ -432,7 +432,28 @@ if __name__ == '__main__':
     else:
         logger.debug('git-buildpackage executed successfully')
         build_log=os.path.join('../build-area/result/', '%s_%s_amd64.build' % (pkg_name, version))
+        # build was succesful, now let's tag it
+        if GIT_BRANCH_NAME == 'master' or GIT_BRANCH_NAME.startswith('hotfix/'):
+            # replace ~ with _ for tags
+            version_tag = version.replace('~','_')
+            if version_tag.find(":"):
+                logger_error('Illegal character ":" in version %s detected. Please use a different version.' % version_tag)
+                exit_error()
+            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', 'push', 'origin', version_tag]
+            try:
+                subprocess.check_call(cmd)
+            except:
+                logger_error('Could not push tag %s to repository.' % version_tag)
+                exit_error()
+            logger.info('Tagged as %s' % version_tag)
         try:
+            # now upload
             create_dput_cfg()
             # strip epoch
             if ":" in version:
@@ -463,21 +484,6 @@ if __name__ == '__main__':
             logger.exception(error)
             exit_error()
 
-        # build was succesful, now let's tag it
-        if GIT_BRANCH_NAME == 'master' or GIT_BRANCH_NAME.startswith('hotfix/'):
-            cmd = ['/usr/bin/git', 'tag', version]
-            try:
-                subprocess.check_call(cmd)
-            except:
-                logger_error('Could not tag repository.')
-                exit_error()
-            cmd = ['/usr/bin/git', 'push', 'origin', version]
-            try:
-                subprocess.check_call(cmd)
-            except:
-                logger_error('Could not push tag.')
-                exit_error()
-
         # finally
         exit_ok()