ABS: Use privileged gerrit account 53/141953/1
authorhyokeun <hyokeun.jeon@samsung.com>
Wed, 2 Aug 2017 05:55:02 +0000 (14:55 +0900)
committerhyokeun <hyokeun.jeon@samsung.com>
Wed, 2 Aug 2017 05:55:02 +0000 (14:55 +0900)
Change-Id: I28efe5d7259ba86d46223952f9adbe43448f81cd

abs/job_abs_build.py

index e5efd7c..f83d2f2 100644 (file)
@@ -276,14 +276,14 @@ def fetch_source(gerrit_env, src_root, project, branch=None, tag=None, patchset=
     clone_gitproject(project, \
                      '%s.git' % os.path.join(gerrit_env.gitcache, project), \
                      gerrit_hostname=gerrit_env.hostname, \
-                     gerrit_username=gerrit_env.username, \
+                     gerrit_username=os.getenv('ABS_GERRIT_USERNAME'), \
                      gerrit_sshport=gerrit_env.sshport, \
                      bare=True)
     print 'Cloning clone %s' % src_root
     if not clone_gitproject(project, \
                             src_root, \
                             gerrit_hostname=gerrit_env.hostname, \
-                            gerrit_username=gerrit_env.username, \
+                            gerrit_username=os.getenv('ABS_GERRIT_USERNAME'), \
                             gerrit_sshport=gerrit_env.sshport):
         raise LocalError('Error cloning project %s' % project)
 
@@ -515,11 +515,8 @@ def post_processing(tizen_studio, src_git, prop, data, builddir, mailer, build):
         mailer.add_message('\n\nGit push branch %s failed %s' % (new_branch, push_err_msg))
         return
 
-    if data.get('gerrit_infra', '').startswith('public_gerrit'):
-        gerrit_env = GerritEnv('PUBLIC_')
-    else:
-        gerrit_env = GerritEnv('')
-    remote = 'ssh://%s@%s:%d/%s' % (gerrit_env.username, \
+    gerrit_env = GerritEnv(data.get('gerrit_infra', ''))
+    remote = 'ssh://%s@%s:%d/%s' % (os.getenv('ABS_GERRIT_USERNAME'), \
                                     gerrit_env.hostname, \
                                     int(gerrit_env.sshport), \
                                     data.get('project'))
@@ -573,8 +570,11 @@ def start_build(fields):
     # Adjust arguments
     data = set_gerrit_event(fields)
 
-    if fields.get('gerrit_infra').startswith('public_gerrit'):
+    print '\n"Title": "%s/%s"\n' % (os.path.basename(data.get('project')), data.get('tag'))
+
+    if fields.get('gerrit_infra').startswith('PUBLIC_'):
         gerrit_env = GerritEnv('PUBLIC_')
+        data['gerrit_infra'] = 'PUBLIC_'
         build = BuildService(os.getenv('PUBLIC_OBS_API_URL'), \
                              os.getenv('PUBLIC_OBS_API_USERNAME'), \
                              os.getenv('PUBLIC_OBS_API_PASSWD'))
@@ -677,9 +677,10 @@ def main(argv):
     # Regular gerrit event (Dispatcher)
     elif os.getenv('GERRIT_PROJECT', None):
 
-        gerrit_infra = ''
         if os.getenv('GERRIT_NAME').startswith('public_gerrit'):
             gerrit_infra = 'PUBLIC_'
+        else:
+            gerrit_infra = ''
         gerrit_env = GerritEnv(gerrit_infra)
 
         project = os.getenv('GERRIT_PROJECT')