Add gitbuildstatus in Prerelease project 49/93649/1
authorYonghee Han <onstudy@samsung.com>
Tue, 25 Oct 2016 06:49:35 +0000 (15:49 +0900)
committerYonghee Han <onstudy@samsung.com>
Tue, 25 Oct 2016 06:49:35 +0000 (15:49 +0900)
Change-Id: I6ed6e93182f732bbf9a5a033a27b88d5b82827d3

common/buildservice.py
job_pre_release_obs.py

index 0cf0cf9..1182af7 100755 (executable)
@@ -859,6 +859,45 @@ class BuildService(OSC):
             raise
         return
 
+
+    def get_build_results(self, prj, view=None, code=None,):
+        """ get build results """
+
+        query = []
+        if view:
+            query.append('view=%s' %(view))
+        else:
+            query.append('view=summary')
+
+        if code:
+            query.append('code=%s' %(code))
+
+        u = core.makeurl(self.apiurl, ['build', prj, '_result'],query=query)
+        try:
+            f = core.http_GET(u)
+            return ''.join(f.readlines())
+        except urllib2.HTTPError, err:
+            print err
+            return err
+
+    def getbuildstatus(self, project):
+        """   get build status """
+        resultdata = {}
+        summarylist = []
+        results_summary = self.get_build_results(project)
+        et = ElementTree.fromstring(''.join(results_summary))
+        for result in et.findall('result'):
+            for summary in result.findall('summary'):
+                for status in summary.findall('statuscount'):
+                    if status.get('code') in ("succeeded","unresolvable","failed"):
+                        summarylist.append({'repo':result.get('repository'), \
+                                            'arch':result.get('arch'), \
+                                            'code':status.get('code'), \
+                                            'count':status.get('count')
+                                            })
+        resultdata['buildstatus'] = summarylist
+        return resultdata
+
     def addPerson(self, prj, users):
         """
         add persons to a project
index 243acef..c1b49be 100755 (executable)
@@ -311,6 +311,10 @@ def main(action):
 
     if action == 'create_images':
         repo = content.get("repo")
+        info = build.get_info(project)
+        buildstatus = build.getbuildstatus(project)
+        print 'buildstatus=%s' %(buildstatus)
+        build.update_buildstatus(buildstatus,project)
 
         # cleanup src.rpm files on Live repo
         # we don't used src.rpm files on prerelease project.