Adding of layout and jjb jobs compatibility job

Added check for availability all jobs from layout in jjb

Change-Id: I3e47bff5fe56bdc40712dcee33f609ee8b481d23
This commit is contained in:
Evgeny Sikachev 2016-09-07 18:29:01 +03:00
parent b19f95d0e9
commit 32e68055e6
4 changed files with 84 additions and 1 deletions

View File

@ -149,6 +149,7 @@ projects:
- name: openstack/sahara-ci-config - name: openstack/sahara-ci-config
check: check:
- sahara-ci-syntax-check - sahara-ci-syntax-check
- sahara-ci-layout
- name: openstack/heat - name: openstack/heat
noop: noop:

View File

@ -0,0 +1,55 @@
#!/usr/bin/env python
import os
import re
import sys
import yaml
layout = yaml.load(open(sys.argv[1]))
def grep(source, pattern):
found = False
p = re.compile(pattern)
for line in source:
if p.match(line):
found = True
break
return found
def get_pipelines():
pipelines = []
for pipeline in layout['pipelines']:
pipelines.append(pipeline['name'])
return pipelines
def check_jobs():
errors = False
pipelines = get_pipelines()
job_list_file = sys.argv[2]
if not os.path.isfile(job_list_file):
print("Job list file %s does not exist, not checking jobs section"
% job_list_file)
return False
with open(job_list_file, 'r') as f:
job_list = [line.rstrip() for line in f]
for project in layout['projects']:
for pipeline in pipelines:
jobs = project.get(pipeline, [])
for job in jobs:
found = grep(job_list, job)
if not found:
print ("Regex %s has no matches in job list" % job)
errors = True
return errors
if __name__ == "__main__":
sys.exit(check_jobs())

9
host-scripts/check_layout.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
mkdir out
jenkins-jobs test -o out/ $WORKSPACE/jenkins_job_builder/
find out/ -printf "%f\n" > job-list.txt
python $WORKSPACE/host-scripts/check_layout.py $WORKSPACE/config/zuul/layout.yaml job-list.txt

View File

@ -71,6 +71,24 @@
publishers: publishers:
- console-log - console-log
- job:
name: sahara-ci-layout
project-type: freestyle
defaults: global
description: "<b>This job is managed by Jenkins Job Builder, do not edit it through WebUI.\
\n<p>Please use this repository to make changes: <a href=\"https://git.openstack.org/openstack/sahara-ci-config\">https://git.openstack.org/openstack/sahara-ci-config</a></b>\
\n<p>This job check compatibility zuul layout and jobs from jjb"
disabled: false
concurrent: false
node: master
builders:
- gerrit-git-prep
- shell: "$WORKSPACE/host-scripts/check_layout.sh"
publishers:
- console-log
- job: - job:
name: update-config name: update-config
node: master node: master