]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
store persistence correctly for changing branch names
authorHolger Levsen <holger@layer-acht.org>
Wed, 26 Oct 2011 17:14:03 +0000 (19:14 +0200)
committerHolger Levsen <holger@layer-acht.org>
Wed, 26 Oct 2011 17:14:03 +0000 (19:14 +0200)
kernel_build.py

index 3877f9b5a37bf7bb0cdd0df9fe63f6fbb5a2dd7e..66b33a5228f98d9109dba1548e72c014cfeab1e8 100644 (file)
@@ -91,20 +91,27 @@ Base.metadata.create_all(engine)
 def get_last_kernel_revision_obj():
     session = Session()
     logger.debug('Getting kernel revision from persistence')
+    if GIT_BRANCH_NAME == 'master' or GIT_BRANCH_NAME.startswith('hotfix'):
+      persistance_identifier = 'master'
+    elif GIT_BRANCH_NAME.startswith('release'):
+      persistance_identifier = 'release'
+    else
+      persistance_identifier = 'develop'
+
     try:
         answ = session.query(KernelVersion).filter(
-                KernelVersion.branch_name == GIT_BRANCH_NAME).one()
+                KernelVersion.branch_name == persistance_identifier).one()
     except NoResultFound:
-        session.add(KernelVersion(GIT_BRANCH_NAME, 0))
+        session.add(KernelVersion(persistance_identifier, 0))
         session.commit()
         answ = session.query(KernelVersion).filter(
-                KernelVersion.branch_name == GIT_BRANCH_NAME).one()
+                KernelVersion.branch_name == persistance_identifier).one()
     finally:
         session.close()
 
     logger.info(
-            'Got this Kernel revision for branch %s: %s'
-            %(GIT_BRANCH_NAME, answ)
+            'Got this Kernel revision for branch %s and persistance_identifier %s: %s'
+            %(GIT_BRANCH_NAME, persistance_identifier, answ)
     )
     return answ