]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
#507: make failed build not failing the jenkins job
authorTobias von der Krone <tobias.vonderkrone@profitbricks.com>
Thu, 4 Jul 2013 07:43:24 +0000 (09:43 +0200)
committerTobias von der Krone <tobias.vonderkrone@profitbricks.com>
Thu, 4 Jul 2013 07:43:24 +0000 (09:43 +0200)
debian_build.py

index 9e36c6ea5b6309d6cd6fecb64be61c14a398644f..016191863ef67c9be20b81231dca0bb76c7a9dbc 100755 (executable)
@@ -111,11 +111,17 @@ if __name__ == '__main__':
     # .. actions, define defaults
     do_autoincrement = False
     do_cidb = False
+    no_cidb_cause = 'default'
     do_cleanup = True
+    no_cleanup_cause = 'unknown'
     do_liveboot_request = False
+    no_liveboot_cause = 'default'
     do_reports = True
+    no_reports_cause = 'unknown'
     do_tagging = False
+    no_tagging_cause = 'default'
     do_uploads = True
+    no_uploads_cause = 'unknown'
 
     # .. repository related
     gitrepo = git.Repo('.')
@@ -198,11 +204,13 @@ if __name__ == '__main__':
             if not do_autoincrement and len(remote_tag) > 0:
                 # FIXME: .id attribute but avl. in wheezy based git lib
                 if remote_tag[0].commit.id == curr_commit_id:
-                    logger.debug('Tag {name} was already created for commit {sha}.'.format(
+                    message = 'Tag {name} was already created for commit {sha}.'.format(
                         name=remote_tag[0].name,
                         sha=remote_tag[0].commit.id[0:7],
-                    ))
+                    )
+                    logger.debug(message)
                     do_tagging = False
+                    no_tagging_cause = message
                 else:
                     logger.error('Tag {name} was already created for commit {sha}.'.format(
                         name=remote_tag[0].name,
@@ -306,7 +314,9 @@ if __name__ == '__main__':
     #
     # .. do some housekeeping first
     if not do_cleanup:
-        figlet('Cleanup skipped')
+        figlet('Cleanup skipped - {cause}'.format(
+            cause=no_cleanup_cause
+        ))
     else:
         # .. reset local repository at first
         logger.info('Reset and clean repository.')
@@ -512,7 +522,13 @@ export {gbp_env} FORCE_SHELL=TRUE
     if ret:
         logger.error('git-buildpackage failed with exitcode {code}'.format(code=ret))
         figlet('Build failed')
-        exit_error()
+        failed_message = 'package build has failed'
+        do_cidb = False
+        no_cidb_cause = failed_message
+        do_liveboot = False
+        no_liveboot_cause = failed_message
+        do_uploads = False
+        no_uploads_cause = failed_message
     else:
         figlet('Build OK')
 
@@ -525,7 +541,9 @@ export {gbp_env} FORCE_SHELL=TRUE
     #    if reports.tgz exists untar it to workspace and delete it.
     #    reports.tgz is generated by /root/.pbuilder/hooks.d/B01-test
     if not do_reports:
-        figlet('Reports skipped')
+        figlet('Reports skipped - {cause}'.format(
+            cause=no_reports_cause
+        ))
     else:
         try:
             reports_file = os.path.join(
@@ -547,7 +565,9 @@ export {gbp_env} FORCE_SHELL=TRUE
 
     # .. let's tag
     if not do_tagging:
-        figlet('Tagging skipped')
+        figlet('Tagging skipped - {cause}'.format(
+            cause=no_tagging_cause
+        ))
     else:
         try:
             gitrepo.git.tag(new_tag)
@@ -568,11 +588,12 @@ export {gbp_env} FORCE_SHELL=TRUE
 
     # .. and upload
     if not do_uploads:
-        figlet('Upload skipped')
+        figlet('Upload skipped - {cause}'.format(
+            cause=no_uploads_cause
+        ))
     else:
         try:
             # strip epoch
-
             dpkg_build_version = new_version
             if ":" in dpkg_build_version:
                 dpkg_build_version = dpkg_build_version.split(":", 1)[1]
@@ -611,7 +632,9 @@ export {gbp_env} FORCE_SHELL=TRUE
 
     # .. and add all the records to CIDB
     if not do_cidb:
-        figlet('CIDB skipped')
+        figlet('CIDB skipped - {cause}'.format(
+            cause=no_cidb_cause
+        ))
     else:
         package_instances = []
         try:
@@ -633,7 +656,9 @@ export {gbp_env} FORCE_SHELL=TRUE
 
     # .. finally trigger the next liveboot automatically if we succeed with CIDB
     if not do_liveboot_request:
-        figlet('Liveboot skipped')
+        figlet('Liveboot skipped - {cause}'.format(
+            cause=no_liveboot_cause
+        ))
     else:
         if len(package_instances) > 0:
             try: