Add support for Slave Utilization plugin

Change-Id: I4243fddf2f08a09671757b503fae2a890f2d820e
This commit is contained in:
Benjamin Staffin 2014-03-24 18:32:29 -07:00
parent 72c02d4106
commit dd14a86a9b
6 changed files with 58 additions and 0 deletions

View File

@ -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.

View File

@ -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 =

View 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>

View File

@ -0,0 +1,4 @@
properties:
- slave-utilization:
slave-percentage: 40
single-instance-per-slave: false

View 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>

View File

@ -0,0 +1,3 @@
properties:
- slave-utilization:
single-instance-per-slave: true