]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
debian_build: log beautifying
authorroot sagunt <root@sagunt.profitbricks.localdomain>
Thu, 6 Jun 2013 10:54:41 +0000 (10:54 +0000)
committerroot sagunt <root@sagunt.profitbricks.localdomain>
Thu, 6 Jun 2013 10:54:41 +0000 (10:54 +0000)
debian_build.py

index 35d1280f45c03df3ecba169910e8b38313480eff..bb1403710a7f567fc5619de944170e688c211916 100755 (executable)
@@ -96,7 +96,7 @@ def getopts():
     return parser.parse_args()
 
 if __name__ == '__main__':
-    logger.debug('Environment:\n{env}'.format(env=pformat(ENV)))
+    logger.debug('Start-up environment:\n\n{env}\n'.format(env=pformat(ENV)))
 
     # Act I: prepare variables
     # .. command line arguments
@@ -264,29 +264,28 @@ if __name__ == '__main__':
     )
 
     # show what we got so far
-    logger.debug('Distribution: "{old_dist}" => "{new_dist}"'.format(
+    logger.info('Changelog distribution: "{old_dist}" => "{new_dist}"'.format(
         old_dist=curr_dist,
         new_dist=new_dist,
     ))
-    logger.debug('Version: "{old_version}" => "{new_version}"'.format(
+    logger.info('Changelog version: "{old_version}" => "{new_version}"'.format(
         old_version=curr_version,
         new_version=new_version,
     ))
-    logger.debug('PB_SUITE: {suite}'.format(
+    logger.info('PB_SUITE (used by pbuilder): {suite}'.format(
         suite=pb_suite,
     ))
     if do_tagging:
-        logger.debug('Tag to create: {tag}'.format(
+        logger.info('Tag to create: {tag}'.format(
             tag=new_tag,
         ))
-    logger.debug('Upload configuration:\n{config}'.format(
-        config=pformat(dput_obj.contents),
+    logger.info('Upload configuration (for reprepro):\n\n{config}\n'.format(
+        config=pformat(dput_obj.contents)
     ))
 
     #
     # ACT III: do something actually
     #
-
     # .. do some housekeeping first
     if not do_cleanup:
         figlet('Cleanup skipped')
@@ -299,9 +298,9 @@ if __name__ == '__main__':
         gitrepo.git.branch('-D', local_branch, with_exceptions=False).strip()
 
         # .. and re-checkout the requested branch
-        logger.info('Checkout branch {branch}.'.format(branch=remote_branch))
-        gitrepo.git.checkout('-b', local_branch, remote_branch).strip()
-        logger.debug('Status is now:\n{status}'.format(
+        logger.info('Checkout branch {branch}.\n\n{checkout}\n{status}\n'.format(
+            branch=remote_branch,
+            checkout=gitrepo.git.checkout('-b', local_branch, remote_branch).strip(),
             status=gitrepo.git.status().strip(),
         ))
 
@@ -315,11 +314,12 @@ if __name__ == '__main__':
 
             if len(files) > 0:
                 logger.info('Delete previous upstream tarball(s)')
-                cmd = [BIN_SUDO, BIN_RM, '-v'] + files
+                cmd = [BIN_SUDO, BIN_RM] + files
+                command = ' '.join(cmd)
                 if subprocess.check_call(cmd) == 0:
-                    logger.info('{command} succeeded.'.format(command=cmd))
+                    logger.debug('%s succeeded.' % command)
                 else:
-                    logger.warn('{command} failed.'.format(cmd))
+                    logger.warn('%s failed.' % command)
 
         figlet('Cleanup OK')
 
@@ -422,14 +422,17 @@ if __name__ == '__main__':
     # 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{changelog}'.format(
-        changelog=''.join([block.__str__() for block in cl._blocks[0:2]])),
-    )
+    logger.info('New changelog:')
+    for block in cl._blocks[0:2]:
+        for line in block.__str__().split('\n'):
+            logger.info('    ' + line)
 
     #
     # ACT IV: preparations are done, let's build
     #
-    logger.info('Building ...')
+    logger.info('Current environment:\n\n{env}\n'.format(env=ENV))
+    logger.info('Start building ...\n')
+
     gbp = git_buildpackage.GitBuildPackage(
         upstream_branch=local_branch,
         debian_branch=local_branch,
@@ -447,20 +450,21 @@ if __name__ == '__main__':
 
     # .. now handle the result
     if ret:
+        figlet('Build failed')
         logger.error('''git-buildpackage failed with exitcode {code}
-## 
-## 
-##  In case you need to analyze errors within chroot, do the following:
-##    * login to {hostname}
-##    * become {jenkins_user}
-##    * cd into {jenkins_workspace}
-##    * then execute:
+### 
+###  In case you need to analyze errors within chroot, do the following:
+###    * login to {hostname}
+###    * become {jenkins_user}
+###    * cd into {jenkins_workspace}
+###    * then execute:
+##
 
 export {gbp_env} FORCE_SHELL=TRUE
 {command}
 
-##
-##
+###
+###
 '''.format(
             code=ret,
             hostname=socket.gethostname(),
@@ -471,10 +475,8 @@ export {gbp_env} FORCE_SHELL=TRUE
                             ]),
             command=' '.join(gbp.command),
         ))
-        figlet('Build failed')
         exit_error()
     else:
-        logger.debug('git-buildpackage executed successfully')
         figlet('Build OK')
 
     #