From a9c6b6f020d94153272a2cb141b559bbb989b43d Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Tue, 27 Sep 2016 14:26:49 -0700 Subject: [PATCH] Add JJB AFS module This adds a JJB module that validates the parameters we use for the afs publisher. This publisher is not an actual Jenkins publisher and only exists in Zuul v2.5's ansible launcher. Thus, it has no XML output and is defined locally in this repo. This also removes the run-layout script (which used to clone HEAD of both jjb and zuul) in favor of installing these dependencies via pip in the tox testenv. We are no longer tracking JJB master, so pinning to the version of JJB we are using makes more sense. Similary, it is not expected that we will need cutting edge versions of zuul for this test in the immediate future (we may want to revisit this when we approach zuulv3). Change-Id: I4acd70c868cb6965d39f968b7582257b4ab21778 --- jenkins/modules/jjb_afs/jjb_afs/__init__.py | 0 jenkins/modules/jjb_afs/jjb_afs/afs.py | 20 ++++++++ jenkins/modules/jjb_afs/setup.py | 24 +++++++++ tools/run-layout.sh | 55 --------------------- tools/zuul.conf-sample | 45 +++++++++++++++++ tox.ini | 20 +++++--- 6 files changed, 103 insertions(+), 61 deletions(-) create mode 100644 jenkins/modules/jjb_afs/jjb_afs/__init__.py create mode 100644 jenkins/modules/jjb_afs/jjb_afs/afs.py create mode 100644 jenkins/modules/jjb_afs/setup.py delete mode 100755 tools/run-layout.sh create mode 100644 tools/zuul.conf-sample diff --git a/jenkins/modules/jjb_afs/jjb_afs/__init__.py b/jenkins/modules/jjb_afs/jjb_afs/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/jenkins/modules/jjb_afs/jjb_afs/afs.py b/jenkins/modules/jjb_afs/jjb_afs/afs.py new file mode 100644 index 0000000000..4101c576e8 --- /dev/null +++ b/jenkins/modules/jjb_afs/jjb_afs/afs.py @@ -0,0 +1,20 @@ +# Copyright 2016 Red Hat, Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from jenkins_jobs.errors import MissingAttributeError + +def afs_publisher(parser, xml_parent, data): + for attr in ['site', 'source', 'target']: + if attr not in data: + raise MissingAttributeError(attr) diff --git a/jenkins/modules/jjb_afs/setup.py b/jenkins/modules/jjb_afs/setup.py new file mode 100644 index 0000000000..c6d95c42e0 --- /dev/null +++ b/jenkins/modules/jjb_afs/setup.py @@ -0,0 +1,24 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import setuptools + +setuptools.setup( + name='jjb_afs', + packages=['jjb_afs'], + version='1.0', + entry_points={ + 'jenkins_jobs.publishers': [ + 'afs=jjb_afs.afs:afs_publisher', + ] + }, + ) diff --git a/tools/run-layout.sh b/tools/run-layout.sh deleted file mode 100755 index 042b080d5f..0000000000 --- a/tools/run-layout.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -e - -# Copyright 2013 OpenStack Foundation -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -mkdir -p .test -cd .test - -echo "Setting up .test" -if [ -d zuul ]; then - echo "Updating zuul" - cd zuul; git pull; cd .. -else - echo "Cloning zuul" - git clone https://git.openstack.org/openstack-infra/zuul --depth 1 -fi - -if [ -d jenkins-job-builder ]; then - echo "Updating jenkins-job-builder" - cd jenkins-job-builder; git pull; cd .. -else - echo "Cloning jenkins-job-builder" - git clone https://git.openstack.org/openstack-infra/jenkins-job-builder --depth 1 -fi - -cd jenkins-job-builder -# These are $WORKSPACE/.test/jenkins-job-builder/.test/... -mkdir -p .test/new/config -mkdir -p .test/new/out -cd ../.. - -cp jenkins/jobs/* .test/jenkins-job-builder/.test/new/config -cd .test/jenkins-job-builder -tox -e compare-xml-new - -# Note that the job-list.txt file is also used by -# tools/layout-checks.py, if this file gets changed, we need to adapt -# the test as well. -cd .. -find jenkins-job-builder/.test/new/out/ -printf "%f\n" > job-list.txt - - -cd zuul -tox -e venv -- zuul-server -c etc/zuul.conf-sample -l ../../zuul/layout.yaml -t ../job-list.txt diff --git a/tools/zuul.conf-sample b/tools/zuul.conf-sample new file mode 100644 index 0000000000..d7b8eaeb55 --- /dev/null +++ b/tools/zuul.conf-sample @@ -0,0 +1,45 @@ +[gearman] +server=127.0.0.1 + +[gearman_server] +start=true + +[zuul] +layout_config=/etc/zuul/layout.yaml +log_config=/etc/zuul/logging.conf +pidfile=/var/run/zuul/zuul.pid +state_dir=/var/lib/zuul +status_url=https://jenkins.example.com/zuul/status + +[merger] +git_dir=/var/lib/zuul/git +;git_user_email=zuul@example.com +;git_user_name=zuul +zuul_url=http://zuul.example.com/p + +[swift] +authurl=https://identity.api.example.org/v2.0/ +user=username +key=password + +default_container=logs +region_name=EXP +logserver_prefix=http://logs.example.org/server.app/ + +[webapp] +listen_address=0.0.0.0 +port=8001 + +[connection gerrit] +driver=gerrit +server=review.example.com +;baseurl=https://review.example.com/r +user=jenkins +sshkey=/home/jenkins/.ssh/id_rsa + +[connection smtp] +driver=smtp +server=localhost +port=25 +default_from=zuul@example.com +default_to=you@example.com diff --git a/tox.ini b/tox.ini index 57771d057c..31f7a3fb73 100644 --- a/tox.ini +++ b/tox.ini @@ -59,8 +59,9 @@ whitelist_externals = rm commands = rm -rf {envdir}/tmp - mkdir -p {envdir}/tmp - jenkins-jobs -l debug test -o {envdir}/tmp jenkins/jobs + mkdir -p {envdir}/tmp/jobs + pip install -U jenkins/modules/jjb_afs + jenkins-jobs -l debug test -o {envdir}/tmp/jobs jenkins/jobs [testenv:jenkins-project] deps = @@ -71,13 +72,20 @@ commands = [testenv:zuul] basepython = python2.7 -deps = PyYAML +deps = + jenkins-job-builder==1.6.1 + zuul whitelist_externals = rm + jenkins-jobs + find commands = - rm -rf .test/jenkins-job-builder/.test/new/out - {toxinidir}/tools/run-layout.sh - {toxinidir}/tools/layout-checks.py + rm -rf {envdir}/tmp + mkdir -p {envdir}/tmp/jobs + pip install -U jenkins/modules/jjb_afs + jenkins-jobs -l debug test -o {envdir}/tmp/jobs jenkins/jobs + bash -c 'find {envdir}/tmp/jobs -printf "%f\n" > {envdir}/tmp/job-list.txt' + zuul-server -c tools/zuul.conf-sample -l zuul/layout.yaml -t {envdir}/tmp/job-list.txt [testenv:infra-docs] deps =