From: Mathias Klette Date: Fri, 3 May 2013 12:41:29 +0000 (+0200) Subject: bugfixes for master branch builds X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=95e9c1229f8468938e0fe747320726b1393585b1;p=profitbricks%2Fjenkins-build-scripts.git bugfixes for master branch builds --- diff --git a/debian_build.py b/debian_build.py index 0c8db1e..d2308bc 100755 --- a/debian_build.py +++ b/debian_build.py @@ -63,11 +63,11 @@ STABLE_DISTRIBUTIONS = ( 'production-proposed-updates' ) STABLE_BRANCHES_RE = re.compile( - '^(master|hotfix/.*)$') + '^(origin/)?(master|hotfix/.*)$') DEVELOP_BRANCHES_RE = re.compile( - '^(develop|pre-staging|release/.*)$') + '^(origin/)?(develop|pre-staging|release/.*)$') EXPERIMENTAL_BRANCHES_RE = re.compile( - '^(experimental|(feature|poc|bugfix)/.*)$') + '^(origin/)?(experimental|(feature|poc|bugfix)/.*)$') def getopts(): usage = '%prog [options]' @@ -124,8 +124,8 @@ if __name__ == '__main__': # .. repository related curr_commit = ENV['GIT_COMMIT'] gitrepo = git.Repo('.') - local_branch = ENV['GIT_BRANCH'] - remote_branch = os.path.join('origin', ENV['GIT_BRANCH']) + local_branch = re.match('^(origin/)?(.*)',ENV['GIT_BRANCH']).groups()[1] + remote_branch = os.path.join('origin', local_branch) reports_file = os.path.join(ENV['WORKSPACE'], '../build-area/result/reports.tgz',) # .. dput related (some overrides happening below, though) @@ -181,7 +181,7 @@ if __name__ == '__main__': do_autoincrement = True # .. fail if we already found the tag we would create upon a successfull build, # except, the existing tag uses the same commit as we were triggered with - remote_tag = [tag for tag in gitrepo.tags if tag.name == version_tag] + remote_tag = [tag for tag in gitrepo.tags if tag.name == new_tag] if len(remote_tag) > 0: if remote_tag[0].commit.id == curr_commit: logger.info('Tag was already created for this commit.') @@ -234,7 +234,7 @@ if __name__ == '__main__': pb_suite = new_dist - # ACT III: actually do something + # ACT III: do something actually # .. do some housekeeping first if not do_cleanup: figlet('Cleanup skipped') @@ -262,7 +262,7 @@ if __name__ == '__main__': )] if len(files) > 0: - logger.info('Delete previous upstream tarball(s)') + logger.debug('Delete previous upstream tarball(s)') cmd = [BIN_SUDO, BIN_RM, '-v'] cmd.extend(files) ret = subprocess.Popen( @@ -278,6 +278,7 @@ if __name__ == '__main__': cmd = cmd, exitcode = ret )) + figlet('Cleanup OK') # .. update changelog if we trust the package if do_autoincrement: @@ -305,6 +306,7 @@ if __name__ == '__main__': ), ] + logger.debug('Executing "%s" ...' %(' '.join(cmd))) dch = subprocess.Popen( cmd, shell=False, @@ -323,20 +325,19 @@ if __name__ == '__main__': gitrepo.git.commit('-a', '-m', 'add new changelog entry') if ret: - logger.debug('"{cmd}" returns {exitcode}.'.format( - cmd = cmd, - exitcode = ret - )) - raise Exception('Failed to update changelog.') + raise Exception( + '"%s" returned with exitcode: %s' %(' '.join(cmd), ret)) # let me see the first two changelog entries: - # TODO: use changelog python libs instead of DCH calls, see above - cl = changelog.Changelog() - cl.parse_changelog(open('debian/changelog')) - logger.info('New changelog:\n\n%s' %( - ''.join([block.__str__() for block in cl._blocks[0:2]]))) - + line_counter = 0 + for line in fileinput.input('debian/changelog'): + if line.startswith(' --'): + line_counter += 1 + if line_counter <= 2: + print('debian/changelog: %s' %(line.rstrip('\n'))) + + # ACT IV: preparations are set, let's build gbp = git_buildpackage.GitBuildPackage( upstream_branch = ENV['GIT_BRANCH'],