Publish 'repa action' event to IRIS
authorZhuoX Li <zhuox.li@intel.com>
Tue, 30 Sep 2014 04:55:44 +0000 (12:55 +0800)
committerLin A Yang <lin.a.yang@intel.com>
Fri, 10 Oct 2014 06:21:36 +0000 (09:21 +0300)
Publish 'repa action' event when a pre-project is accepted/rejected
by repa.

Change-Id: Ia5d7968793aba0a124ea78f82e4e10b70e4213e6

job_request.py

index 66854bd..ac7e43d 100755 (executable)
@@ -9,6 +9,7 @@ from common.gerrit import Gerrit, GerritError
 from common.buildtrigger import trigger_info, trigger_next
 from common.send_mail import prepare_mail
 from common.buildservice import BuildService
+from common.iris_rest_client import IrisRestClient
 from obs_requests.mailer import mailer
 from gbp.git.repository import GitRepositoryError
 from gitbuildsys.errors import ObsError
@@ -16,6 +17,7 @@ from gitbuildsys.errors import ObsError
 import sys
 import os
 import datetime
+import base64
 from xml.sax.saxutils import unescape
 
 # set default char-set endcoding to utf-8
@@ -319,6 +321,20 @@ def main():
         print 'Invalid OBS event'
         return -1
 
+    # add repa_action log for iris
+    pub_enabled = os.getenv("IRIS_PUB_ENABLED", "0") != "0"
+    if pub_enabled:
+        rest = IrisRestClient(
+            os.getenv("IRIS_SERVER"),
+            os.getenv("IRIS_USERNAME"),
+            base64.b64decode(os.getenv('IRIS_PASSWORDX','')))
+        rest.publish_event("repa_action", {
+            "project": event_fields.get('sourceproject'),
+            "status": event_fields.get('state'),
+            "who": event_fields.get('who'),
+            "when": event_fields.get('when'),
+            "reason": event_fields.get('comment'),
+            })
     try:
         data, projects_data = obs_git_data(event_fields)
     except GitError, err: