From 7b96be1572ba31de69cf47acb96e4476e3f45416 Mon Sep 17 00:00:00 2001 From: apoorvad Date: Tue, 15 Dec 2015 11:43:57 -0800 Subject: [PATCH] Separate votes from Jenkins queues It was seen that all the queues for Jenkins post the vote under same ci_owner. This patch separates out the votes based on the queues. Also includes performance improvements during compilation of regex patterns. Change-Id: I998749316d0b0488068ca20f9be68faf3caecd3a Closes-Bug: #1517677 --- ciwatch/events.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/ciwatch/events.py b/ciwatch/events.py index bd090ac..0fd1d2a 100644 --- a/ciwatch/events.py +++ b/ciwatch/events.py @@ -23,21 +23,34 @@ from ciwatch import db from ciwatch.log import logger from ciwatch import models +pipeline_pattern = re.compile("\((.*)\spipeline\)") + +possible_results = "FAILURE|SUCCESS|NOT_REGISTERED|UNSTABLE" +comment_pattern = re.compile("[-*]\s+([^\s*]+)\s+(http[^\s*]+) : (%s)" % + possible_results) +jenkins_check = "Jenkins check" + def _process_project_name(project_name): return project_name.split('/')[-1] +def is_jenkins_pipeline(line): + match = pipeline_pattern.search(line) + if match is not None: + return match.group(1) + + def _process_event(event): comment = event['comment'] # Find all the CIs voting in this comment lines = comment.splitlines() event['ci-status'] = {} + pipeline = is_jenkins_pipeline(lines[0]) + if pipeline is not None: + event["author"]["name"] = event["author"]["name"] + ' ' + pipeline for line in lines: - possible_results = "FAILURE|SUCCESS|NOT_REGISTERED|UNSTABLE" - pattern = re.compile("[-*]\s+([^\s*]+)\s+(http[^\s*]+) : (%s)" % - possible_results) - match = pattern.search(line) + match = comment_pattern.search(line) if match is not None: ci_name = match.group(1) log_url = match.group(2) @@ -131,7 +144,7 @@ def add_event_to_db(event, commit_=True): commit_message=event['change']['commitMessage'], created=datetime.fromtimestamp( int(event['patchSet']['createdOn']))) - trusted = (event["author"]["username"] == "jenkins") + trusted = (event["author"]["name"] == jenkins_check) if trusted and "approvals" in event: if event["approvals"][0]["value"] in ("1", "2"):