Merge "Add support for Slave Utilization plugin"
This commit is contained in:
commit
ceae497aa2
@ -533,6 +533,36 @@ def heavy_job(parser, xml_parent, data):
|
||||
data.get('weight', 1))
|
||||
|
||||
|
||||
def slave_utilization(parser, xml_parent, data):
|
||||
"""yaml: slave-utilization
|
||||
This plugin allows you to specify the percentage of a slave's capacity a
|
||||
job wants to use.
|
||||
|
||||
Requires the Jenkins `Slave Utilization Plugin.
|
||||
<https://wiki.jenkins-ci.org/display/JENKINS/Slave+Utilization+Plugin>`_
|
||||
|
||||
:arg int slave-percentage: Specify the percentage of a slave's execution
|
||||
slots that this job should occupy (default: 0)
|
||||
:arg bool single-instance-per-slave: Control whether concurrent instances
|
||||
of this job will be permitted to run in parallel on a single slave
|
||||
(default: False)
|
||||
|
||||
Example:
|
||||
|
||||
.. literalinclude:: \
|
||||
/../../tests/properties/fixtures/slave-utilization1.yaml
|
||||
"""
|
||||
utilization = XML.SubElement(
|
||||
xml_parent, 'com.suryagaddipati.jenkins.SlaveUtilizationProperty')
|
||||
percent = int(data.get('slave-percentage', 0))
|
||||
XML.SubElement(utilization, 'needsExclusiveAccessToNode'
|
||||
).text = 'true' if percent else 'false'
|
||||
XML.SubElement(utilization, 'slaveUtilizationPercentage'
|
||||
).text = str(percent)
|
||||
XML.SubElement(utilization, 'singleInstancePerSlave').text = str(
|
||||
data.get('single-instance-per-slave', False)).lower()
|
||||
|
||||
|
||||
def delivery_pipeline(parser, xml_parent, data):
|
||||
"""yaml: delivery-pipeline
|
||||
Requires the Jenkins `Delivery Pipeline Plugin.
|
||||
|
@ -68,6 +68,7 @@ jenkins_jobs.properties =
|
||||
ownership=jenkins_jobs.modules.properties:ownership
|
||||
priority-sorter=jenkins_jobs.modules.properties:priority_sorter
|
||||
promoted-build=jenkins_jobs.modules.properties:promoted_build
|
||||
slave-utilization=jenkins_jobs.modules.properties:slave_utilization
|
||||
throttle=jenkins_jobs.modules.properties:throttle
|
||||
zeromq-event=jenkins_jobs.modules.properties:zeromq_event
|
||||
jenkins_jobs.parameters =
|
||||
|
10
tests/properties/fixtures/slave-utilization1.xml
Normal file
10
tests/properties/fixtures/slave-utilization1.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<com.suryagaddipati.jenkins.SlaveUtilizationProperty>
|
||||
<needsExclusiveAccessToNode>true</needsExclusiveAccessToNode>
|
||||
<slaveUtilizationPercentage>40</slaveUtilizationPercentage>
|
||||
<singleInstancePerSlave>false</singleInstancePerSlave>
|
||||
</com.suryagaddipati.jenkins.SlaveUtilizationProperty>
|
||||
</properties>
|
||||
</project>
|
4
tests/properties/fixtures/slave-utilization1.yaml
Normal file
4
tests/properties/fixtures/slave-utilization1.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
properties:
|
||||
- slave-utilization:
|
||||
slave-percentage: 40
|
||||
single-instance-per-slave: false
|
10
tests/properties/fixtures/slave-utilization2.xml
Normal file
10
tests/properties/fixtures/slave-utilization2.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<com.suryagaddipati.jenkins.SlaveUtilizationProperty>
|
||||
<needsExclusiveAccessToNode>false</needsExclusiveAccessToNode>
|
||||
<slaveUtilizationPercentage>0</slaveUtilizationPercentage>
|
||||
<singleInstancePerSlave>true</singleInstancePerSlave>
|
||||
</com.suryagaddipati.jenkins.SlaveUtilizationProperty>
|
||||
</properties>
|
||||
</project>
|
3
tests/properties/fixtures/slave-utilization2.yaml
Normal file
3
tests/properties/fixtures/slave-utilization2.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
properties:
|
||||
- slave-utilization:
|
||||
single-instance-per-slave: true
|
Loading…
x
Reference in New Issue
Block a user