Add deadline option for build-timeout plugin
Change-Id: I475d28c41292fe7be66c1c0a574da8960e4b73ec Signed-off-by: Kien Ha <kienha9922@gmail.com>
This commit is contained in:
parent
be0948dfb1
commit
377f8378fe
@ -265,6 +265,7 @@ def timeout(parser, xml_parent, data):
|
|||||||
* **no-activity**
|
* **no-activity**
|
||||||
* **elastic**
|
* **elastic**
|
||||||
* **absolute**
|
* **absolute**
|
||||||
|
* **deadline**
|
||||||
|
|
||||||
:arg int elastic-percentage: Percentage of the three most recent builds
|
:arg int elastic-percentage: Percentage of the three most recent builds
|
||||||
where to declare a timeout, only applies to **elastic** type.
|
where to declare a timeout, only applies to **elastic** type.
|
||||||
@ -274,6 +275,12 @@ def timeout(parser, xml_parent, data):
|
|||||||
:arg int elastic-default-timeout: Timeout to use if there were no previous
|
:arg int elastic-default-timeout: Timeout to use if there were no previous
|
||||||
builds, only applies to **elastic** type. (default 3)
|
builds, only applies to **elastic** type. (default 3)
|
||||||
|
|
||||||
|
:arg str deadline-time: Build terminate automatically at next deadline time
|
||||||
|
(HH:MM:SS), only applies to **deadline** type. (default 0:00:00)
|
||||||
|
:arg int deadline-tolerance: Period in minutes after deadline when a job
|
||||||
|
should be immediately aborted, only applies to **deadline** type.
|
||||||
|
(default 1)
|
||||||
|
|
||||||
Example (Version < 1.14):
|
Example (Version < 1.14):
|
||||||
|
|
||||||
.. literalinclude:: /../../tests/wrappers/fixtures/timeout/timeout001.yaml
|
.. literalinclude:: /../../tests/wrappers/fixtures/timeout/timeout001.yaml
|
||||||
@ -296,6 +303,9 @@ def timeout(parser, xml_parent, data):
|
|||||||
.. literalinclude::
|
.. literalinclude::
|
||||||
/../../tests/wrappers/fixtures/timeout/version-1.14/elastic001.yaml
|
/../../tests/wrappers/fixtures/timeout/version-1.14/elastic001.yaml
|
||||||
|
|
||||||
|
.. literalinclude::
|
||||||
|
/../../tests/wrappers/fixtures/timeout/version-1.15/deadline001.yaml
|
||||||
|
|
||||||
"""
|
"""
|
||||||
prefix = 'hudson.plugins.build__timeout.'
|
prefix = 'hudson.plugins.build__timeout.'
|
||||||
twrapper = XML.SubElement(xml_parent, prefix + 'BuildTimeoutWrapper')
|
twrapper = XML.SubElement(xml_parent, prefix + 'BuildTimeoutWrapper')
|
||||||
@ -304,7 +314,8 @@ def timeout(parser, xml_parent, data):
|
|||||||
"Jenkins build timeout plugin")
|
"Jenkins build timeout plugin")
|
||||||
version = pkg_resources.parse_version(plugin_info.get("version", "0"))
|
version = pkg_resources.parse_version(plugin_info.get("version", "0"))
|
||||||
|
|
||||||
valid_strategies = ['absolute', 'no-activity', 'likely-stuck', 'elastic']
|
valid_strategies = ['absolute', 'no-activity', 'likely-stuck', 'elastic',
|
||||||
|
'deadline']
|
||||||
|
|
||||||
if version >= pkg_resources.parse_version("1.14"):
|
if version >= pkg_resources.parse_version("1.14"):
|
||||||
strategy = data.get('type', 'absolute')
|
strategy = data.get('type', 'absolute')
|
||||||
@ -345,6 +356,18 @@ def timeout(parser, xml_parent, data):
|
|||||||
XML.SubElement(strategy_element, 'timeoutMinutesElasticDefault'
|
XML.SubElement(strategy_element, 'timeoutMinutesElasticDefault'
|
||||||
).text = str(data.get('elastic-default-timeout', 3))
|
).text = str(data.get('elastic-default-timeout', 3))
|
||||||
|
|
||||||
|
elif strategy == "deadline":
|
||||||
|
strategy_element = XML.SubElement(
|
||||||
|
twrapper, 'strategy',
|
||||||
|
{'class': "hudson.plugins.build_timeout."
|
||||||
|
"impl.DeadlineTimeOutStrategy"})
|
||||||
|
deadline_time = str(data.get('deadline-time', '0:00:00'))
|
||||||
|
XML.SubElement(strategy_element,
|
||||||
|
'deadlineTime').text = str(deadline_time)
|
||||||
|
deadline_tolerance = int(data.get('deadline-tolerance', 1))
|
||||||
|
XML.SubElement(strategy_element, 'deadlineToleranceInMinutes'
|
||||||
|
).text = str(deadline_tolerance)
|
||||||
|
|
||||||
actions = []
|
actions = []
|
||||||
|
|
||||||
for action in ['fail', 'abort']:
|
for action in ['fail', 'abort']:
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
- longName: 'Jenkins build timeout plugin'
|
||||||
|
shortName: 'build-timeout'
|
||||||
|
version: "1.15"
|
15
tests/wrappers/fixtures/timeout/version-1.15/deadline001.xml
Normal file
15
tests/wrappers/fixtures/timeout/version-1.15/deadline001.xml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<buildWrappers>
|
||||||
|
<hudson.plugins.build__timeout.BuildTimeoutWrapper>
|
||||||
|
<strategy class="hudson.plugins.build_timeout.impl.DeadlineTimeOutStrategy">
|
||||||
|
<deadlineTime>0:00:00</deadlineTime>
|
||||||
|
<deadlineToleranceInMinutes>1</deadlineToleranceInMinutes>
|
||||||
|
</strategy>
|
||||||
|
<operationList>
|
||||||
|
<hudson.plugins.build__timeout.operations.AbortOperation/>
|
||||||
|
</operationList>
|
||||||
|
<timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
|
||||||
|
</hudson.plugins.build__timeout.BuildTimeoutWrapper>
|
||||||
|
</buildWrappers>
|
||||||
|
</project>
|
@ -0,0 +1,6 @@
|
|||||||
|
wrappers:
|
||||||
|
- timeout:
|
||||||
|
deadline-time: '0:00:00'
|
||||||
|
deadline-tolerance: 1
|
||||||
|
timeout-var: 'BUILD_TIMEOUT'
|
||||||
|
type: deadline
|
Loading…
x
Reference in New Issue
Block a user