ABS: Remove previous tpk tag if the same build was requested 49/168249/1
authorhyokeun <hyokeun.jeon@samsung.com>
Thu, 25 Jan 2018 07:38:18 +0000 (16:38 +0900)
committerhyokeun <hyokeun.jeon@samsung.com>
Thu, 25 Jan 2018 07:38:18 +0000 (16:38 +0900)
Change-Id: I4354a830daf3cf72f3a58a53cef0712da297cb03

abs/job_abs_build.py
common/git.py

index 188b57f..d1345d3 100755 (executable)
@@ -44,6 +44,7 @@ from common.send_mail import prepare_mail
 from common.workflow import find_specfile, parse_specfile
 from common.tizen_studio import TizenStudio
 
+
 # set default char-set endcoding to utf-8
 reload(sys)
 sys.setdefaultencoding('utf-8') # pylint: disable-msg=E1101
@@ -536,6 +537,12 @@ def post_processing(tizen_studio, src_git, prop, data, builddir, mailer, build):
     spec = generate_spec_file(tizen_studio, src_git, prop, data)
     print 'SPEC:\n%s' % spec
 
+    gerrit_env = get_gerrit_infra(data.get('gerrit_infra', 'LOCAL'))
+    remote = 'ssh://%s@%s:%d/%s' % (gerrit_env.get('username'), \
+                                    gerrit_env.get('hostname'), \
+                                    gerrit_env.get('sshport'), \
+                                    data.get('project'))
+
     #TODO: Checkout _tpk branch and push the tpks and tag it
     new_branch = data.get('new_branch')
     new_tag = data.get('new_tag')
@@ -557,11 +564,17 @@ def post_processing(tizen_studio, src_git, prop, data, builddir, mailer, build):
         print 'Checking tag [%s]' % chk_tag
         if chk_tag:
             print 'Tag(%s) already exist.' % new_tag
-            mailer.add_title('The same tag exist')
-            mailer.add_message('Result: FAIL')
-            mailer.add_message('\n\nTag %s already exist.' % new_tag)
-            return
-    except:
+            #TODO: Force remove previous tag...
+            if True:
+                src_git.delete_tag(new_tag)
+                src_git.remove_tag_from_remote(remote, new_tag)
+            else:
+                mailer.add_title('The same tag exist')
+                mailer.add_message('Result: FAIL')
+                mailer.add_message('\n\nTag %s already exist.' % new_tag)
+                return
+    except Exception as err:
+        print repr(err)
         pass
     try:
         src_git.remove_files('*')
@@ -607,12 +620,6 @@ 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
 
-    gerrit_env = get_gerrit_infra(data.get('gerrit_infra', 'LOCAL'))
-    remote = 'ssh://%s@%s:%d/%s' % (gerrit_env.get('username'), \
-                                    gerrit_env.get('hostname'), \
-                                    gerrit_env.get('sshport'), \
-                                    data.get('project'))
-
     message = '%s\n' \
         '[ABS] Ready.\n' \
         '- Original Tag: %s (%s)\n' \
@@ -716,7 +723,7 @@ def start_build(fields):
 
     project_properties = retrieve_project_property(src_git, int_tag)
 
-    #FIXME:
+    #FIXME: 
     if project_properties.get('sdk_profile') == "" or project_properties.get('sdk_profile') is None:
         if "mobile" in data.get('project'):
             project_properties['sdk_profile'] = "mobile"
@@ -768,7 +775,7 @@ def start_build(fields):
     # Make tarball to share source codes easily with vm machine
     zipping_workspace(src_root)
 
-    parallel_jobs = ''
+    parallel_jobs = '"-j 1"'
     #if data.get('buildcheck'):
     #    parallel_jobs = '"-j 4"'
     #### Running QEMU to launch Tizen Studio ####
@@ -809,7 +816,7 @@ def start_build(fields):
             mailer.send_mail()
             #TODO: DASHBOARD
             update_dashboard(int_tag, data, project_properties, \
-                 status='failed', status_reason=fail_log[len(fail_log)-1024:], \
+                 status='failed', status_reason=fail_log, \
                  rootstrap_version=rs_ver.strip(), \
                  tizen_studio_version=ts_version, \
                  tizen_studio_distribution=ts_distribution)
@@ -829,7 +836,7 @@ def start_build(fields):
     if 'FAIL' in mailer.email_title:
         #TODO: DASHBOARD 
         update_dashboard(int_tag, data, project_properties, \
-             status='failed', status_reason=fail_log[len(fail_log)-1024:], \
+             status='failed', status_reason=fail_log, \
              rootstrap_version=rs_ver.strip(), \
              tizen_studio_version=ts_version, \
              tizen_studio_distribution=ts_distribution)
index 75ba2dc..b4df238 100644 (file)
@@ -179,6 +179,14 @@ class Git(GitRepository):
         else:
             return (br in self.get_branches()[1])
 
+    def remove_tag_from_remote(self, remote, tag):
+        """Remove tag from the remote
+          @param remote: complete url
+        """
+
+        args = GitArgs(remote, ':' + tag)
+        self._git_command("push", args.args)
+
 def _update_gitproject(localdir, gitpath=None):
     """Fetch latest code to local dir"""
 
@@ -270,7 +278,7 @@ def clone_gitproject(gerritprj, localdir, giturl=None, bare=False, gerrit_hostna
         if not gerrit_hostname or not gerrit_username or not gerrit_sshport:
             giturl = 'ssh://%s@%s:%s' % (os.getenv('GERRIT_USERNAME'),
                                         os.getenv('GERRIT_HOSTNAME'),
-                                        os.getenv('GERRIT_SSHPORT'))
+                                         os.getenv('GERRIT_SSHPORT'))
         else:
             giturl = 'ssh://%s@%s:%s' % (gerrit_username,gerrit_hostname,gerrit_sshport)
 
@@ -284,9 +292,9 @@ def fetch_change(gerritprj, localdir, refspec, giturl=None, bare=False, gerrit_h
     if not giturl:
         if not gerrit_hostname or not gerrit_username or not gerrit_sshport:
             giturl = 'ssh://%s@%s:%s/%s' % (os.getenv('GERRIT_USERNAME'),
-                                          os.getenv('GERRIT_HOSTNAME'),
+                                           os.getenv('GERRIT_HOSTNAME'),
                                            os.getenv('GERRIT_SSHPORT'),
-                                          gerritprj)
+                                           gerritprj)
         else:
             giturl = 'ssh://%s@%s:%s' % (gerrit_username,gerrit_hostname,gerrit_sshport,gerritprj)