]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
no duplicate build log output
authorHolger Levsen <holger@layer-acht.org>
Wed, 8 Feb 2012 15:25:01 +0000 (16:25 +0100)
committerHolger Levsen <holger@layer-acht.org>
Thu, 9 Feb 2012 13:16:57 +0000 (14:16 +0100)
debian_build.py
lib/git_helper.py

index fd32029442be88977826cb6ff16847abebd6fcaf..66b97bddd3a03e074f2911e4b31fd02220af2527 100755 (executable)
@@ -80,7 +80,7 @@ DPUT_OPTIONS_DEV = {
         'allow_unsigned_uploads': 1,
         'post_upload_command': 'ssh reprepro@alexandria.profitbricks.localdomain /srv/dev-repository/bin/pb_processincoming',
         }
-DPUT_CF = os.path.join(GIT_TARGET_WORKSPACE, 'dput.cf')
+DPUT_CF = os.path.join(CWD, '..', 'dput.cf')
 
 NO_UPLOAD = os.environ.get('NO_UPLOAD')
 
@@ -234,16 +234,16 @@ if __name__ == '__main__':
                 )
             )
     )
-    logging.getLogger('lib.git_helper').setLevel(logging.DEBUG)
+    #logging.getLogger('lib.git_helper').setLevel(logging.DEBUG)
     options, args = getopts()
-    if git_helper.git_clone_remote_repository(GIT_REPO_PATH, GIT_TARGET_DIR):
-        logger.info('git clone was successfull')
-    else:
-        logger_loud_error('git clone was not successfull')
-        exit_error()
+    #if git_helper.git_clone_remote_repository(GIT_REPO_PATH, GIT_TARGET_DIR):
+    #    logger.info('git clone was successfull')
+    #else:
+    #    logger_loud_error('git clone was not successfull')
+    #    exit_error()
 
-    atexit.register(remove_git_target_workspace)
-    os.chdir(GIT_TARGET_DIR)
+    #atexit.register(remove_git_target_workspace)
+    #os.chdir(GIT_TARGET_DIR)
 
     # FIXME: this is just needed for gbp and can go away eventually
     if GIT_BRANCH_NAME:
@@ -259,8 +259,8 @@ if __name__ == '__main__':
 
     repo = git.repo.Repo()
 
-    if GIT_BRANCH_NAME != 'master':
-        git_helper.git_new_branch_from(
+    #if GIT_BRANCH_NAME != 'master':
+    git_helper.git_new_branch_from(
                 GIT_BRANCH_NAME,
                 os.path.join('origin', GIT_BRANCH_NAME)
         )
@@ -269,16 +269,16 @@ if __name__ == '__main__':
     # treeish refspec when a name was given (i.e. tag names, branch names, 
     # etc.)
     # TODO: upgrade git-buildpackage
-    GIT_UPSTREAM_BRANCH = git_helper.git_get_treeish(
-        os.path.join('origin', GIT_UPSTREAM_BRANCH)
-    )
+    #GIT_UPSTREAM_BRANCH = git_helper.git_get_treeish(
+    #    os.path.join('origin', GIT_UPSTREAM_BRANCH)
+    #)
 
     # now checkout the requested branch
-    if git_helper.git_checkout_branch(GIT_UPSTREAM_BRANCH):
-        logger.info('git checkout %s was successfull' % GIT_UPSTREAM_BRANCH)
-    else:
-        logger_loud_error('git checkout %s was not successfull' % GIT_UPSTREAM_BRANCH)
-        exit_error()
+    #if git_helper.git_checkout_branch(GIT_UPSTREAM_BRANCH):
+    #    logger.info('git checkout %s was successfull' % GIT_UPSTREAM_BRANCH)
+    #else:
+    #    logger_loud_error('git checkout %s was not successfull' % GIT_UPSTREAM_BRANCH)
+    #    exit_error()
 
     # we need to make sure our jenkins config is used, so let's delete any 
     # other config available in repository that might be prefered 
@@ -435,6 +435,10 @@ if __name__ == '__main__':
 
     logger.info('used to start git-buildpackage here...')
     ret = gbp.build()
+    # remove last commit (the one where we added the changelog entry)
+    cmd = ['/usr/bin/git', 'reset', '--soft', 'HEAD~1']
+    subprocess.check_call(cmd)
+    # now handle gpb result
     if ret:
         logger_loud_error(
                 'git-buildpackage returned non-zero. exitcode was: %s' % ret
@@ -444,12 +448,12 @@ if __name__ == '__main__':
         logger.debug('git-buildpackage executed successfully')
 #    if not ret:
         build_log=os.path.join('../build-area/result/', '%s_%s_amd64.build' % (pkg_name, version))
-        try:
-          fh = open(build_log, 'r')
-          logger.debug('Output of the deb build: %s' % (fh.read()))
-          fh.close()
-       except:
-         pass
+#        try:
+#          fh = open(build_log, 'r')
+#          logger.debug('Output of the deb build: %s' % (fh.read()))
+#          fh.close()
+#      except:
+#        pass
 #        exit_error()
 #    else:
         try:
@@ -457,7 +461,7 @@ if __name__ == '__main__':
             # strip epoch
             if ":" in version:
                 version = version.split(":", 1)[1]
-            changes_file =  os.path.join(GIT_TARGET_WORKSPACE, 'build-area/result/', '%s_%s_amd64.changes' % (pkg_name, version))
+            changes_file =  os.path.join(CWD, '../build-area/result/', '%s_%s_amd64.changes' % (pkg_name, version))
             # display changes file
             fh = open(changes_file, 'r')
             logger.info('%s' % (fh.read()))
index f6020b548ebf5a3a40f344e88bef600345746806..48fa7c9f2d77503b8e26b5ffaddcdea2cf433378 100644 (file)
@@ -71,10 +71,26 @@ def git_clone_remote_repository(url, destination):
     return True
 
 def git_new_branch_from(branch_name, from_branch):
+    if git_repo_has_branch(branch_name):
+        cmd = [GIT, 'branch', '-D', branch_name]
+
+        cmdobj = subprocess.Popen(
+                cmd,
+                shell=False,
+                close_fds=True,
+                stderr=subprocess.PIPE,
+                stdout=subprocess.PIPE,
+                env={'':''},
+                cwd=os.getcwd()
+        )
+
+    # this should not happen, we just deleted it
     if git_repo_has_branch(branch_name):
         raise BranchExistError(branch_name)
-#    if not git_repo_has_branch(from_branch):
-#        raise BranchNotExistError(from_branch)
+
+    #if not git_repo_has_branch(from_branch):
+    #    raise BranchNotExistError(from_branch)
+
     cmd = [GIT, 'checkout', '-b', branch_name, from_branch]
 
     cmdobj = subprocess.Popen(
@@ -117,9 +133,9 @@ def git_checkout_branch(branch_name):
     # and there is proper error handling below anyway...
     #if not git_repo_has_branch(branch_name):
     #raise BranchNotExistError(branch_name)
-
     cmd = [GIT, 'checkout', branch_name]
 
+
     cmdobj = subprocess.Popen(
             cmd,
             shell=False,