Merge "Added support for Exclusion plugin"
This commit is contained in:
commit
a9fb1bec14
@ -1048,6 +1048,64 @@ def sbt(parser, xml_parent, data):
|
||||
'subdir-path', '')
|
||||
|
||||
|
||||
def critical_block_start(parser, xml_parent, data):
|
||||
"""yaml: critical-block-start
|
||||
Designate the start of a critical block. Must be used in conjuction with
|
||||
critical-block-end.
|
||||
|
||||
Must also add a build wrapper (exclusion), specifying the resources that
|
||||
control the critical block. Otherwise, this will have no effect.
|
||||
|
||||
Requires Jenkins `Exclusion Plugin.
|
||||
<https://wiki.jenkins-ci.org/display/JENKINS/Exclusion-Plugin>`_
|
||||
|
||||
Example::
|
||||
|
||||
wrappers:
|
||||
- exclusion:
|
||||
resources:
|
||||
myresource1
|
||||
builders:
|
||||
- critical-block-start
|
||||
- ... other builders
|
||||
- critical-block-end
|
||||
|
||||
"""
|
||||
cbs = \
|
||||
XML.SubElement(xml_parent,
|
||||
'org.jvnet.hudson.plugins.exclusion.CriticalBlockStart')
|
||||
cbs.set('plugin', 'Exclusion')
|
||||
|
||||
|
||||
def critical_block_end(parser, xml_parent, data):
|
||||
"""yaml: critical-block-end
|
||||
Designate the end of a critical block. Must be used in conjuction with
|
||||
critical-block-start.
|
||||
|
||||
Must also add a build wrapper (exclusion), specifying the resources that
|
||||
control the critical block. Otherwise, this will have no effect.
|
||||
|
||||
Requires Jenkins `Exclusion Plugin.
|
||||
<https://wiki.jenkins-ci.org/display/JENKINS/Exclusion-Plugin>`_
|
||||
|
||||
Example::
|
||||
|
||||
wrappers:
|
||||
- exclusion:
|
||||
resources:
|
||||
myresource1
|
||||
builders:
|
||||
- critical-block-start
|
||||
- ... other builders
|
||||
- critical-block-end
|
||||
|
||||
"""
|
||||
cbs = \
|
||||
XML.SubElement(xml_parent,
|
||||
'org.jvnet.hudson.plugins.exclusion.CriticalBlockEnd')
|
||||
cbs.set('plugin', 'Exclusion')
|
||||
|
||||
|
||||
class Builders(jenkins_jobs.modules.base.Base):
|
||||
sequence = 60
|
||||
|
||||
|
@ -969,6 +969,34 @@ def matrix_tie_parent(parser, xml_parent, data):
|
||||
XML.SubElement(mtp, 'labelName').text = data['node']
|
||||
|
||||
|
||||
def exclusion(parser, xml_parent, data):
|
||||
"""yaml: exclusion
|
||||
Add a resource to use for critical sections to establish a mutex on. If
|
||||
another job specifies the same resource, the second job will wait for the
|
||||
blocked resource to become available.
|
||||
|
||||
Requires the Jenkins `Exclusion Plugin.
|
||||
<https://wiki.jenkins-ci.org/display/JENKINS/Exclusion-Plugin>`_
|
||||
|
||||
:arg list resources: List of resources to add for exclusion
|
||||
|
||||
Example:
|
||||
|
||||
.. literalinclude:: /../../tests/wrappers/fixtures/exclusion002.yaml
|
||||
|
||||
"""
|
||||
exl = XML.SubElement(xml_parent,
|
||||
'org.jvnet.hudson.plugins.exclusion.IdAllocator')
|
||||
exl.set('plugin', 'Exclusion')
|
||||
ids = XML.SubElement(exl, 'ids')
|
||||
resources = data.get('resources', [])
|
||||
for resource in resources:
|
||||
dit = \
|
||||
XML.SubElement(ids,
|
||||
'org.jvnet.hudson.plugins.exclusion.DefaultIdType')
|
||||
XML.SubElement(dit, 'name').text = str(resource).upper()
|
||||
|
||||
|
||||
class Wrappers(jenkins_jobs.modules.base.Base):
|
||||
sequence = 80
|
||||
|
||||
|
@ -41,6 +41,8 @@ jenkins_jobs.builders =
|
||||
builders-from=jenkins_jobs.modules.builders:builders_from
|
||||
conditional-step=jenkins_jobs.modules.builders:conditional_step
|
||||
copyartifact=jenkins_jobs.modules.builders:copyartifact
|
||||
critical-block-start=jenkins_jobs.modules.builders:critical_block_start
|
||||
critical-block-end=jenkins_jobs.modules.builders:critical_block_end
|
||||
gradle=jenkins_jobs.modules.builders:gradle
|
||||
grails=jenkins_jobs.modules.builders:grails
|
||||
inject=jenkins_jobs.modules.builders:inject
|
||||
@ -174,6 +176,7 @@ jenkins_jobs.wrappers =
|
||||
copy-to-slave=jenkins_jobs.modules.wrappers:copy_to_slave
|
||||
delivery-pipeline=jenkins_jobs.modules.wrappers:delivery_pipeline
|
||||
env-file=jenkins_jobs.modules.wrappers:env_file
|
||||
exclusion=jenkins_jobs.modules.wrappers:exclusion
|
||||
inject-passwords=jenkins_jobs.modules.wrappers:inject_passwords
|
||||
inject=jenkins_jobs.modules.wrappers:inject
|
||||
jclouds=jenkins_jobs.modules.wrappers:jclouds
|
||||
|
6
tests/builders/fixtures/critical-block-end.xml
Normal file
6
tests/builders/fixtures/critical-block-end.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jvnet.hudson.plugins.exclusion.CriticalBlockEnd plugin="Exclusion"/>
|
||||
</builders>
|
||||
</project>
|
2
tests/builders/fixtures/critical-block-end.yaml
Normal file
2
tests/builders/fixtures/critical-block-end.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
builders:
|
||||
- critical-block-end
|
6
tests/builders/fixtures/critical-block-start.xml
Normal file
6
tests/builders/fixtures/critical-block-start.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jvnet.hudson.plugins.exclusion.CriticalBlockStart plugin="Exclusion"/>
|
||||
</builders>
|
||||
</project>
|
2
tests/builders/fixtures/critical-block-start.yaml
Normal file
2
tests/builders/fixtures/critical-block-start.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
builders:
|
||||
- critical-block-start
|
7
tests/builders/fixtures/critical-block.xml
Normal file
7
tests/builders/fixtures/critical-block.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<builders>
|
||||
<org.jvnet.hudson.plugins.exclusion.CriticalBlockStart plugin="Exclusion"/>
|
||||
<org.jvnet.hudson.plugins.exclusion.CriticalBlockEnd plugin="Exclusion"/>
|
||||
</builders>
|
||||
</project>
|
3
tests/builders/fixtures/critical-block.yaml
Normal file
3
tests/builders/fixtures/critical-block.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
builders:
|
||||
- critical-block-start
|
||||
- critical-block-end
|
12
tests/wrappers/fixtures/exclusion001.xml
Normal file
12
tests/wrappers/fixtures/exclusion001.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<buildWrappers>
|
||||
<org.jvnet.hudson.plugins.exclusion.IdAllocator plugin="Exclusion">
|
||||
<ids>
|
||||
<org.jvnet.hudson.plugins.exclusion.DefaultIdType>
|
||||
<name>MYRESOURCE</name>
|
||||
</org.jvnet.hudson.plugins.exclusion.DefaultIdType>
|
||||
</ids>
|
||||
</org.jvnet.hudson.plugins.exclusion.IdAllocator>
|
||||
</buildWrappers>
|
||||
</project>
|
4
tests/wrappers/fixtures/exclusion001.yaml
Normal file
4
tests/wrappers/fixtures/exclusion001.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
wrappers:
|
||||
- exclusion:
|
||||
resources:
|
||||
- myresource
|
15
tests/wrappers/fixtures/exclusion002.xml
Normal file
15
tests/wrappers/fixtures/exclusion002.xml
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<buildWrappers>
|
||||
<org.jvnet.hudson.plugins.exclusion.IdAllocator plugin="Exclusion">
|
||||
<ids>
|
||||
<org.jvnet.hudson.plugins.exclusion.DefaultIdType>
|
||||
<name>MYRESOURCE1</name>
|
||||
</org.jvnet.hudson.plugins.exclusion.DefaultIdType>
|
||||
<org.jvnet.hudson.plugins.exclusion.DefaultIdType>
|
||||
<name>MYRESOURCE2</name>
|
||||
</org.jvnet.hudson.plugins.exclusion.DefaultIdType>
|
||||
</ids>
|
||||
</org.jvnet.hudson.plugins.exclusion.IdAllocator>
|
||||
</buildWrappers>
|
||||
</project>
|
5
tests/wrappers/fixtures/exclusion002.yaml
Normal file
5
tests/wrappers/fixtures/exclusion002.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
wrappers:
|
||||
- exclusion:
|
||||
resources:
|
||||
- myresource1
|
||||
- myresource2
|
18
tests/wrappers/fixtures/exclusion003.xml
Normal file
18
tests/wrappers/fixtures/exclusion003.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<buildWrappers>
|
||||
<org.jvnet.hudson.plugins.exclusion.IdAllocator plugin="Exclusion">
|
||||
<ids>
|
||||
<org.jvnet.hudson.plugins.exclusion.DefaultIdType>
|
||||
<name>MYRESOURCE1</name>
|
||||
</org.jvnet.hudson.plugins.exclusion.DefaultIdType>
|
||||
<org.jvnet.hudson.plugins.exclusion.DefaultIdType>
|
||||
<name>MYRESOURCE2</name>
|
||||
</org.jvnet.hudson.plugins.exclusion.DefaultIdType>
|
||||
<org.jvnet.hudson.plugins.exclusion.DefaultIdType>
|
||||
<name>MYRESOURCE3</name>
|
||||
</org.jvnet.hudson.plugins.exclusion.DefaultIdType>
|
||||
</ids>
|
||||
</org.jvnet.hudson.plugins.exclusion.IdAllocator>
|
||||
</buildWrappers>
|
||||
</project>
|
6
tests/wrappers/fixtures/exclusion003.yaml
Normal file
6
tests/wrappers/fixtures/exclusion003.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
wrappers:
|
||||
- exclusion:
|
||||
resources:
|
||||
- myResource1
|
||||
- MyresoUrce2
|
||||
- myReSoUrCe3
|
Loading…
Reference in New Issue
Block a user