From 7d319fc9b902d5948b5ed1f25b68f90477ed57f7 Mon Sep 17 00:00:00 2001 From: "william.soula" Date: Sat, 10 Nov 2012 12:18:25 -0600 Subject: [PATCH] Adding ability to use the Locks and Latches plugin Change-Id: I8c63de4eebd42dbe2274a560b038ffe3f7cf8598 Reviewed-on: https://review.openstack.org/15891 Reviewed-by: Clark Boylan Approved: James E. Blair Reviewed-by: James E. Blair Tested-by: Jenkins --- jenkins_jobs/modules/wrappers.py | 25 +++++++++++++++++++++++++ setup.py | 1 + 2 files changed, 26 insertions(+) diff --git a/jenkins_jobs/modules/wrappers.py b/jenkins_jobs/modules/wrappers.py index 29e3227ad..02b3acbaa 100644 --- a/jenkins_jobs/modules/wrappers.py +++ b/jenkins_jobs/modules/wrappers.py @@ -188,6 +188,31 @@ def port_allocator(parser, xml_parent, data): XML.SubElement(dpt, 'name').text = data['name'] +def locks(parser, xml_parent, data): + """yaml: locks + Control parallel execution of jobs. + Requires the Jenkins `Locks and Latches Plugin. + `_ + + :arg: list of locks to use + + Example:: + + wrappers: + - locks: + - FOO + - FOO2 + """ + lw = XML.SubElement(xml_parent, + 'hudson.plugins.locksandlatches.LockWrapper') + locktop = XML.SubElement(lw, 'locks') + locks = data + for lock in locks: + lockwrapper = XML.SubElement(locktop, + 'hudson.plugins.locksandlatches.LockWrapper_-LockWaitConfig') + XML.Sublement(lockwrapper, 'name').text = lock + + class Wrappers(jenkins_jobs.modules.base.Base): sequence = 80 diff --git a/setup.py b/setup.py index 9a11eddd5..5ca7df250 100644 --- a/setup.py +++ b/setup.py @@ -118,6 +118,7 @@ setuptools.setup( 'workspace-cleanup=jenkins_jobs.modules.wrappers:' 'workspace_cleanup', 'port-allocator=jenkins_jobs.modules.wrappers:port_allocator', + 'locks=jenkins_jobs.modules.wrappers:locks', ], 'jenkins_jobs.modules': [ 'assignednode=jenkins_jobs.modules.assignednode:AssignedNode',