Add support for multiple port allocations

Change-Id: I156bccebdd392cd4a912599b5a2c815587e77134
This commit is contained in:
Brian Saville 2014-10-29 12:20:53 -06:00
parent e1e10e266e
commit ab0aa1adfd
5 changed files with 52 additions and 9 deletions

View File

@ -22,6 +22,7 @@ Wrappers can alter the way the build is run as well as the build output.
"""
import logging
import xml.etree.ElementTree as XML
import jenkins_jobs.modules.base
from jenkins_jobs.errors import JenkinsJobsException
@ -440,22 +441,29 @@ def port_allocator(parser, xml_parent, data):
Requires the Jenkins `Port Allocator Plugin.
<https://wiki.jenkins-ci.org/display/JENKINS/Port+Allocator+Plugin>`_
:arg str name: Variable name of the port or a specific port number
:arg str name: Deprecated, use names instead
:arg list names: Variable list of names of the port or list of
specific port numbers
Example::
Example:
wrappers:
- port-allocator:
name: SERVER_PORT
.. literalinclude:: /../../tests/wrappers/fixtures/port-allocator002.yaml
"""
pa = XML.SubElement(xml_parent,
'org.jvnet.hudson.plugins.port__allocator.'
'PortAllocator')
ports = XML.SubElement(pa, 'ports')
dpt = XML.SubElement(ports,
'org.jvnet.hudson.plugins.port__allocator.'
'DefaultPortType')
XML.SubElement(dpt, 'name').text = data['name']
names = data.get('names')
if not names:
logger = logging.getLogger(__name__)
logger.warn('port_allocator name is deprecated, use a names list '
' instead')
names = [data['name']]
for name in names:
dpt = XML.SubElement(ports,
'org.jvnet.hudson.plugins.port__allocator.'
'DefaultPortType')
XML.SubElement(dpt, 'name').text = name
def locks(parser, xml_parent, data):

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<org.jvnet.hudson.plugins.port__allocator.PortAllocator>
<ports>
<org.jvnet.hudson.plugins.port__allocator.DefaultPortType>
<name>SERVER_PORT</name>
</org.jvnet.hudson.plugins.port__allocator.DefaultPortType>
</ports>
</org.jvnet.hudson.plugins.port__allocator.PortAllocator>
</buildWrappers>
</project>

View File

@ -0,0 +1,3 @@
wrappers:
- port-allocator:
name: SERVER_PORT

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<buildWrappers>
<org.jvnet.hudson.plugins.port__allocator.PortAllocator>
<ports>
<org.jvnet.hudson.plugins.port__allocator.DefaultPortType>
<name>SERVER_PORT</name>
</org.jvnet.hudson.plugins.port__allocator.DefaultPortType>
<org.jvnet.hudson.plugins.port__allocator.DefaultPortType>
<name>SERVER_PORT2</name>
</org.jvnet.hudson.plugins.port__allocator.DefaultPortType>
</ports>
</org.jvnet.hudson.plugins.port__allocator.PortAllocator>
</buildWrappers>
</project>

View File

@ -0,0 +1,5 @@
wrappers:
- port-allocator:
names:
- SERVER_PORT
- SERVER_PORT2