]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
debian_build: when rebase failed use some more actions to recover
authorMathias Klette <mathias.klette@profitbricks.com>
Sun, 16 Jun 2013 01:49:01 +0000 (03:49 +0200)
committerMathias Klette <mathias.klette@profitbricks.com>
Sun, 16 Jun 2013 01:49:01 +0000 (03:49 +0200)
-------- Original-Nachricht --------
Betreff: Jenkins Build dev_vdc-bundle - failed rebase not cleaned up correctly
Datum:   Fri, 14 Jun 2013 20:33:44 +0200
Von:   Ramona Koch <ramona.koch@profitbricks.com>
Antwort an:  ramona.koch@profitbricks.com
An:   dcops <dcops@profitbricks.com>, Core <core@profitbricks.com>, Mehrdad Arifi <mehrdad.arifi@profitbricks.com>

Hi DC Ops, Hi Core, Hi Mehrdad

I just noticed, that the 'workspace' is not correctly cleaned up, if the rebase had failed.
All builds trying to merge afterwards will also fail during rebase with:

It seems that I cannot create a rebase-apply directory, and I wonder if you are in the middle of patch application or another
rebase.  If that is not the case, please
    rm -fr /var/lib/jenkins/jobs/dev_vdc-bundles/workspace/.git/rebase-apply
and run me again.  I am stopping in case you still have something valuable there.

@DCOps:
I checked your debian_build.py at:

 337             try:
 338                 src_branch = local_branch        # save the original branch
 339                 dst_branch = 'integration'       # define the new branch
 340                 local_branch = dst_branch        # reset env for
git-buildpackage
 341                 gitrepo.git.rebase('origin/' + dst_branch)
 342                 gitrepo.git.checkout(dst_branch)
 343                 gitrepo.git.pull()
 344                 gitrepo.git.merge(src_branch)
 345                 logger.info('Rebase and merge from branch "{src_branch}"
completed. Now in "{dst_branch}".'.format(
 346                     dst_branch=dst_branch,
 347                     src_branch=src_branch,
 348                 ))
 349             except Exception as error:
 350                 logger.error('Rebase has failed!', exc_info=error)
 351                 gitrepo.git.reset('--hard',src_branch)
 352                 exit_error()

and I assume that 'git reset --hard' is not enough. Probably a 'git rebase --abort' needs to be done before. If this does not work - simply removing the mentioned file will work.
Could you check, if my assumption is correct and fix it, please.

debian_build.py

index 8b76cc010361d2321f53514296897a1ce93f2aec..9c085f7317971afb5204d5baa6417ccccddb6aa0 100755 (executable)
@@ -343,17 +343,18 @@ if __name__ == '__main__':
                 src_branch = local_branch        # save the original branch
                 dst_branch = 'integration'       # define the new branch
                 local_branch = dst_branch        # reset env for git-buildpackage
-                gitrepo.git.rebase('origin/' + dst_branch)
-                gitrepo.git.checkout(dst_branch)
-                gitrepo.git.pull()
-                gitrepo.git.merge(src_branch)
+                logger.debug(gitrepo.git.rebase('origin/' + dst_branch))
+                logger.debug(gitrepo.git.checkout(dst_branch))
+                logger.debug(gitrepo.git.pull())
+                logger.debug(gitrepo.git.merge(src_branch))
                 logger.info('Rebase and merge from branch "{src_branch}" completed. Now in "{dst_branch}".'.format(
                     dst_branch=dst_branch,
                     src_branch=src_branch,
                 ))
             except Exception as error:
-                logger.error('Rebase has failed!', exc_info=error)
-                gitrepo.git.reset('--hard',src_branch)
+                logger.error('Rebase has failed!\n\n%s\n' % error.stderr, exc_info=error)
+                logger.debug(gitrepo.git.rebase('--abort'))
+                logger.debug(gitrepo.git.reset('--hard',src_branch))
                 exit_error()
 
         if 'no-test' in build_triggers: