
This is the first in a series of changes to alter the way modules are handled. This change removes the module section from yaml. Instead, all files in modules/ are imported, and a 'register' function is called if it exists. The register function can add (any number of) module classes to a module registry. The registry will also keep track of helper functions for use by other modules, and the register function can add those. This sets up the ability for a module other than the 'builders' module to register builders. Eventually, we should be able to move all OpenStack specific builders, publishers, etc outside of the base modules; instead we would just register an 'openstack_pep8' builder in a module of our own that the job filler would know to invoke. The API for modules is slightly changed, adding a root_xml method to handle the different project types, a handle_data method for modules that want to modify the yaml data structure before any XML is generated, and a data parameter is added to the generate_xml method. Ideally, we will migrate those modules that count on having a centrally stored data object to using the one passed into this method to allow maximum flexibility. I also envision some project-level yaml attributes to be moved closer to the handlers that use them. This change does inadvertently alter the XML produced. Here is the result of test.sh: http://paste.openstack.org/show/18585/ In all cases, those are inconsistencies in the YAML that are corrected by this change. Some jobs included an empty triggers vector (due to module trigger_none) while others did not, so there was no way to satisfy both behaviors. The added postbuilder section in the gerrit maven job is there because the job specified postbuilders, but did not include the postbuilder module. I believe the resulting XML is more desirable. Change-Id: Ib38222e6bfc9d5b55aa497669d7023c7aaf4b7bc
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
#! /usr/bin/env python
|
|
# Copyright (C) 2012 OpenStack, LLC.
|
|
#
|
|
# 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.
|
|
|
|
# Jenkins Job module for assigned nodes
|
|
# To use add the folowing into your YAML:
|
|
# assignednode:
|
|
# - node: 'oneiric'
|
|
|
|
import xml.etree.ElementTree as XML
|
|
|
|
|
|
def register(registry):
|
|
mod = AssignedNode()
|
|
registry.registerModule(mod)
|
|
|
|
|
|
class AssignedNode(object):
|
|
sequence = 40
|
|
|
|
def gen_xml(self, xml_parent, data):
|
|
node = data['assignednode']['node']
|
|
XML.SubElement(xml_parent, 'assignedNode').text = node
|
|
XML.SubElement(xml_parent, 'canRoam').text = 'false'
|
|
|