]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
handle errors properly
authorHolger Levsen <holger@layer-acht.org>
Thu, 20 Sep 2012 11:36:08 +0000 (13:36 +0200)
committerHolger Levsen <holger@layer-acht.org>
Thu, 20 Sep 2012 11:36:08 +0000 (13:36 +0200)
debian_build.py

index 2186313ce9a7d3da16edd54871d3df2328cf61cb..21bb67c4192248d62cc702ed890f3b0023a6115f 100755 (executable)
@@ -130,8 +130,7 @@ def db_add_job(con, name):
     cur = con.cursor()
     cur.execute("SAVEPOINT a")
     try:
-        cur.execute("INSERT INTO jenkins_job(name) VALUES(%s)"
-                " RETURNING id", (name))
+        cur.execute("INSERT INTO jenkins_job(name) VALUES(%s)")
         logger.debug("saved %s to databased" %(job_name))
     except psycopg2.DatabaseError as e:
     # record already exist
@@ -604,7 +603,6 @@ if __name__ == '__main__':
         # upload (if NO_UPLOAD is not set)
         if NO_UPLOAD not in ('true', 'True'):
             dput_package_upload(changes_file)
-            add_package_instance("profitbricks", BUILD_JOBNAME, BUILD_NUMBER, changes_file, version)
         else:
             logger.debug('value of NO_UPLOAD: %s' % NO_UPLOAD)
         logger.info('dist: %s' %(pb_suite))
@@ -613,15 +611,21 @@ if __name__ == '__main__':
         logger.info('version: %s' %(version))
         cmd = ['figlet-figlet', '-t', 'version: %s' %(version)]
         subprocess.check_call(cmd)
-        logger.info('---------------------------------------------------------------------------------------------------------')
-        cmd = ['figlet-figlet', '-t', 'Success!!!']
-        subprocess.check_call(cmd)
 
     except Exception, error:
         cmd = ['figlet-figlet', '-t', 'upload to reprepro failed:']
         subprocess.check_call(cmd)
         logger.exception(error)
         exit_error()
+    logger.info('---------------------------------------------------------------------------------------------------------')
+    cmd = ['figlet-figlet', '-t', 'Success!!!']
+    subprocess.check_call(cmd)
+    try:
+         add_package_instance("profitbricks", BUILD_JOBNAME, BUILD_NUMBER, changes_file, version)
+    except Exception, error:
+        cmd = ['figlet-figlet', '-t', 'package instance not added to DB']
+        subprocess.check_call(cmd)
+        exit_error()
 
     # finally
     exit_ok()