]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
bugfixes for master branch builds
authorMathias Klette <mathias.klette@profitbricks.com>
Fri, 3 May 2013 12:41:29 +0000 (14:41 +0200)
committerMathias Klette <mathias.klette@profitbricks.com>
Fri, 3 May 2013 12:41:29 +0000 (14:41 +0200)
debian_build.py

index 0c8db1eae4cd77da4d922af41926ec0dade14a1e..d2308bcc2e9a558970dc4bf544cba92bb82f1f5f 100755 (executable)
@@ -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'],