From: Holger Levsen Date: Fri, 14 Dec 2012 17:00:37 +0000 (+0100) Subject: test for existing tag early and fail early, so that people dont waste their time... X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=6d2d3b5fba7218edd92dee7de40bea456d105a53;p=profitbricks%2Fjenkins-build-scripts.git test for existing tag early and fail early, so that people dont waste their time waiting for a build which will fail later anyway. --- diff --git a/debian_build.py b/debian_build.py index a026b4d..3aa3e79 100755 --- a/debian_build.py +++ b/debian_build.py @@ -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/'):