Add support for the Branch API Plugin
Change-Id: I3ed06a4ef957cb088bda8b9a5881d642f68cbe3d
This commit is contained in:
parent
b402d7800c
commit
3e44a52336
@ -280,6 +280,47 @@ def throttle(registry, xml_parent, data):
|
|||||||
matrixopt, data, mapping, fail_required=True)
|
matrixopt, data, mapping, fail_required=True)
|
||||||
|
|
||||||
|
|
||||||
|
def branch_api(registry, xml_parent, data):
|
||||||
|
"""yaml: branch-api
|
||||||
|
Enforces a minimum time between builds based on the desired maximum rate.
|
||||||
|
Requires the Jenkins :jenkins-wiki:`Branch API Plugin
|
||||||
|
<Branch+API+Plugin>`.
|
||||||
|
|
||||||
|
:arg int number-of-builds: The maximum number of builds allowed within
|
||||||
|
the specified time period. (default 1)
|
||||||
|
:arg str time-period: The time period within which the maximum number
|
||||||
|
of builds will be enforced. (default 'Hour')
|
||||||
|
|
||||||
|
:valid values:
|
||||||
|
* **Hour**
|
||||||
|
* **Day**
|
||||||
|
* **Week**
|
||||||
|
* **Month**
|
||||||
|
* **Year**
|
||||||
|
|
||||||
|
Minimal Example:
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
/../../tests/properties/fixtures/branch-api-minimal.yaml
|
||||||
|
:language: yaml
|
||||||
|
|
||||||
|
Full example:
|
||||||
|
|
||||||
|
.. literalinclude:: /../../tests/properties/fixtures/branch-api-full.yaml
|
||||||
|
:language: yaml
|
||||||
|
"""
|
||||||
|
branch = XML.SubElement(xml_parent, 'jenkins.branch.'
|
||||||
|
'RateLimitBranchProperty_-JobPropertyImpl')
|
||||||
|
branch.set('plugin', 'branch-api')
|
||||||
|
|
||||||
|
valid_time_periods = ['Hour', 'Day', 'Week', 'Month', 'Year']
|
||||||
|
|
||||||
|
mapping = [
|
||||||
|
('time-period', 'durationName', 'Hour', valid_time_periods),
|
||||||
|
('number-of-builds', 'count', 1)]
|
||||||
|
helpers.convert_mapping_to_xml(branch, data, mapping, fail_required=True)
|
||||||
|
|
||||||
|
|
||||||
def sidebar(registry, xml_parent, data):
|
def sidebar(registry, xml_parent, data):
|
||||||
"""yaml: sidebar
|
"""yaml: sidebar
|
||||||
Allows you to add links in the sidebar.
|
Allows you to add links in the sidebar.
|
||||||
|
9
tests/properties/fixtures/branch-api-full.xml
Normal file
9
tests/properties/fixtures/branch-api-full.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<properties>
|
||||||
|
<jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl plugin="branch-api">
|
||||||
|
<durationName>Day</durationName>
|
||||||
|
<count>5</count>
|
||||||
|
</jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl>
|
||||||
|
</properties>
|
||||||
|
</project>
|
5
tests/properties/fixtures/branch-api-full.yaml
Normal file
5
tests/properties/fixtures/branch-api-full.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
properties:
|
||||||
|
- branch-api:
|
||||||
|
time-period: Day
|
||||||
|
number-of-builds: 5
|
||||||
|
|
9
tests/properties/fixtures/branch-api-minimal.xml
Normal file
9
tests/properties/fixtures/branch-api-minimal.xml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<properties>
|
||||||
|
<jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl plugin="branch-api">
|
||||||
|
<durationName>Hour</durationName>
|
||||||
|
<count>1</count>
|
||||||
|
</jenkins.branch.RateLimitBranchProperty_-JobPropertyImpl>
|
||||||
|
</properties>
|
||||||
|
</project>
|
2
tests/properties/fixtures/branch-api-minimal.yaml
Normal file
2
tests/properties/fixtures/branch-api-minimal.yaml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
properties:
|
||||||
|
- branch-api
|
Loading…
Reference in New Issue
Block a user