]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
use cidb_dev database for liveboot_development jobs
authorFabian Holler <fabian.holler@profitbricks.com>
Wed, 30 Jan 2013 11:48:29 +0000 (12:48 +0100)
committerHolger Levsen <holger@layer-acht.org>
Wed, 30 Jan 2013 12:05:20 +0000 (13:05 +0100)
if the env variable GIT_BRANCH == "master" the database "cidb" is used
else "cidb_dev" is used as db

cidb.py

diff --git a/cidb.py b/cidb.py
index 5ddde11e102893f9cecdd24b61cc23a420d139de..28aaf7a2361280590be5354935302918a8e2e0b1 100644 (file)
--- a/cidb.py
+++ b/cidb.py
@@ -1,34 +1,30 @@
 #!/usr/bin/python
 
-import subprocess
+import logging
+import os
 import psycopg2
 import psycopg2.extras
-import logging
+import subprocess
 
-# get current git branch
-#p = subprocess.Popen(["git", "rev-parse", "--symbolic-full-name",
-#    "--abbrev-ref", "HEAD"], stdout=subprocess.PIPE)
-#p.wait()
-#branch = p.stdout.read().rstrip()
+logger = logging.getLogger()
 
-#if branch == "master":
-DB_USER = "cidb"
-DB_PASSWD = "cidb"
-DB_NAME = "cidb"
-DB_HOST = "jenkins"
-DB_PORT = 5432
-#else:
-#    DB_USER = "cidb_dev"
-#    DB_PASSWD = "cidb_dev"
-#    DB_NAME = "cidb_dev"
-#    DB_HOST = "jenkins"
-#    DB_PORT = 5432
+if os.environ['GIT_BRANCH'] == "master":
+    DB_USER = "cidb"
+    DB_PASSWD = "cidb"
+    DB_NAME = "cidb"
+    DB_HOST = "jenkins"
+    DB_PORT = 5432
+else:
+    DB_USER = "cidb_dev"
+    DB_PASSWD = "cidb_dev"
+    DB_NAME = "cidb_dev"
+    DB_HOST = "jenkins"
+    DB_PORT = 5432
 
-logger = logging.getLogger()
+print(DB_NAME)
 
-def db_connect():
-    """ Connects to the db and returns the Connection object. """
 
-    #logger.info("Connecting to database %s" % DB_NAME)
+def db_connect():
+    logger.info("Connecting to database %s" % DB_NAME)
     return psycopg2.connect(database=DB_NAME, user=DB_USER, password=DB_PASSWD,
             host=DB_HOST, port=DB_PORT)