#!/usr/bin/python import argparse import sys import subprocess import json import re import datetime # Do not include the -nv suffix in the job name here. The code will handle # reading both the voting and non-voting forms of the job if they exist. DEFAULT_JOB_NAMES = [ 'tripleo-ci-centos-7-containers-multinode', 'tripleo-ci-centos-7-scenario001-multinode-oooq-container', 'tripleo-ci-centos-7-scenario002-multinode-oooq-container', 'tripleo-ci-centos-7-scenario003-multinode-oooq-container', 'tripleo-ci-centos-7-scenario004-multinode-oooq-container', 'tripleo-ci-centos-7-scenario007-multinode-oooq-container', 'tripleo-ci-centos-7-undercloud-containers,' 'tripleo-ci-centos-7-3nodes-multinode', 'tripleo-ci-centos-7-undercloud-upgrades', ] DEFAULT_PROJECTS = [ 'openstack/tripleo-heat-templates', 'openstack/dib-utils', 'openstack/diskimage-builder', 'openstack/instack', 'openstack/instack-undercloud', 'openstack/os-apply-config', 'openstack/os-collect-config', 'openstack/os-net-config', 'openstack/os-refresh-config', 'openstack/paunch', 'openstack/python-tripleoclient', 'openstack-infra/tripleo-ci', 'openstack/tripleo-common', 'openstack/tripleo-image-elements', 'openstack/tripleo-puppet-elements', 'openstack/mistral', '^openstack/puppet-.*', ] COLORS = {"SUCCESS": "#008800", "FAILURE": "#FF0000", "ABORTED": "#000000"} def get_gerrit_reviews(project, status="open", branch="master", limit="30"): arr = [] status_query = '' if status: status_query = 'status: %s' % status cmd = 'ssh review.openstack.org -p29418 gerrit' \ ' query "%s project: %s branch: %s" --comments' \ ' --format JSON limit: %s --patch-sets --current-patch-set'\ % (status_query, project, branch,limit) p = subprocess.Popen([cmd], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout = p.stdout for line in stdout.readlines(): review = json.loads(line) if 'project' in review: arr.append(review) return arr def get_jenkins_comment_message(review): jenkins_messages = {} for comment in review['comments']: if 'name' in comment['reviewer']: if comment['reviewer']['name'] == 'Zuul': if "NOT_REGISTERED" in comment['message']: continue # NOTE(bnemec): For some reason the experimental-tripleo # message does not include "pipeline". if ('tripleo-ci' not in comment['message']): continue jenkins_messages[comment['timestamp']] = comment['message'] return jenkins_messages def process_jenkins_comment_message(message, job_names): job_results = {} for line in message.split('\n'): if line and line[0] == '-': split = line.split(" ",6) voting_job_name = split[1] if voting_job_name.endswith('-nv'): voting_job_name = voting_job_name[:-3] if voting_job_name in job_names: if len(split) > 6: duration = " ".join(split[6].split()[:2]) else: duration = '' job_results[voting_job_name] = {'log_url': split[2], 'status': split[4], 'duration': duration} return job_results def gen_html(data, html_file, table_file, stats_hours, job_names, options): fp = open(table_file, "w") fp.write('
") for job_name in job_names: fp.write(" | %s | " % job_name.replace("tripleo-ci-centos-7-", "")) fp.write("|
")
fp.write(result['timestamp'])
fp.write(" ") fp.write(result['project']) fp.write("/") fp.write(result['branch']) fp.write(" ") fp.write(result['status']) fp.write(" | ")
job_columns = ""
result_types = set()
for job_name in job_names:
if job_name in result['ci_results']:
job_columns += ""
ci_result = result['ci_results'][job_name]
color = COLORS.get(ci_result['status'], "#666666")
result_types.add(ci_result['status'])
job_columns += '' % color
gerrit_href = 'https://review.openstack.org/#/c/%s/%s"' % (
result['url'].split('/')[-1], result['patchset']
)
job_columns += '%s,%s' % \
(color, gerrit_href, result['url'].split('/')[-1],
result['patchset'])
job_columns += ' %s ' % (ci_result['duration']) job_columns += 'log' %\ ci_result['log_url'] job_columns += ' ' job_columns += " | "
else:
job_columns += "" # For the purpose of these stats, let's ignore POST_FAILURE jobs result_types.discard('POST_FAILURE') if len(result_types) > 1: partial_jobs += 1 elif 'FAILURE' in result_types: failed_jobs += 1 else: passed_jobs += 1 fp.write(job_columns) fp.write(" |