From 88d5d405fdac6263bbf5b6a4cd86b3f58db9ebd5 Mon Sep 17 00:00:00 2001 From: "william.soula" Date: Tue, 6 Nov 2012 21:02:30 -0600 Subject: [PATCH] Adding ability to use the Port Allocator Plugin Change-Id: Ie64b4d3d0b1812347f6cc5921dc1cb5bb22ea27f Reviewed-on: https://review.openstack.org/15402 Approved: James E. Blair Reviewed-by: James E. Blair Tested-by: Jenkins --- jenkins_jobs/modules/wrappers.py | 22 ++++++++++++++++++++++ setup.py | 1 + 2 files changed, 23 insertions(+) diff --git a/jenkins_jobs/modules/wrappers.py b/jenkins_jobs/modules/wrappers.py index 905893371..29e3227ad 100644 --- a/jenkins_jobs/modules/wrappers.py +++ b/jenkins_jobs/modules/wrappers.py @@ -166,6 +166,28 @@ def build_name(parser, xml_parent, data): XML.SubElement(bsetter, 'template').text = data['name'] +def port_allocator(parser, xml_parent, data): + """yaml: port-allocator + Assign unique TCP port numbers + Requires the Jenkins `Port Allocator Plugin. + `_ + + :arg str name: Variable name of the port or a specific port number + + Example:: + + wrappers: + - port-allocator: + name: SERVER_PORT + """ + 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'] + + class Wrappers(jenkins_jobs.modules.base.Base): sequence = 80 diff --git a/setup.py b/setup.py index a1cb0a9fb..194062126 100644 --- a/setup.py +++ b/setup.py @@ -97,6 +97,7 @@ setup(name='jenkins_job_builder', 'build-name=jenkins_jobs.modules.wrappers:build_name', 'workspace-cleanup=jenkins_jobs.modules.wrappers:' 'workspace_cleanup', + 'port-allocator=jenkins_jobs.modules.wrappers:port_allocator', ], 'jenkins_jobs.modules': [ 'assignednode=jenkins_jobs.modules.assignednode:AssignedNode',