Updated BuildTimeoutWrapper plugin
On version 1.17 of BuildTimeoutWrapper plugin, new option called "AbortAndRestart" has been introduced. The plugin support has been updated in order to support this option. A test case also added. Change-Id: I4bcbdbc45e177fc4d302baa68898e89463535f6f Signed-off-by: Eren ATAS <eatas.contractor@libertyglobal.com>
This commit is contained in:
parent
cf8b2721ed
commit
6b3d7d806b
@ -275,8 +275,13 @@ def timeout(registry, xml_parent, data):
|
||||
|
||||
:arg bool fail: Mark the build as failed (default false)
|
||||
:arg bool abort: Mark the build as aborted (default false)
|
||||
:arg bool abort-and-restart: Mark the build as aborted, then restart.
|
||||
Count of restarts can be set via `max-restarts`
|
||||
(default false) (Version >= 1.17).
|
||||
:arg bool write-description: Write a message in the description
|
||||
(default false)
|
||||
:arg int max-restarts: Count of maximum restarts.
|
||||
0 means without a limit (default 0) (Version >= 1.17).
|
||||
:arg int timeout: Abort the build after this number of minutes (default 3)
|
||||
:arg str timeout-var: Export an environment variable to reference the
|
||||
timeout value (optional)
|
||||
@ -430,9 +435,13 @@ def timeout(registry, xml_parent, data):
|
||||
strategy_element, data, mapping, fail_required=True
|
||||
)
|
||||
|
||||
all_actions = ["fail", "abort"]
|
||||
actions = []
|
||||
|
||||
for action in ["fail", "abort"]:
|
||||
if version is not None and version >= pkg_resources.parse_version("1.17"):
|
||||
all_actions.append("abort-and-restart")
|
||||
|
||||
for action in all_actions:
|
||||
if str(data.get(action, "false")).lower() == "true":
|
||||
actions.append(action)
|
||||
|
||||
@ -444,6 +453,8 @@ def timeout(registry, xml_parent, data):
|
||||
if description is not None:
|
||||
actions.append("write-description")
|
||||
|
||||
max_restarts = data.get("max-restarts", "0")
|
||||
|
||||
operation_list = XML.SubElement(twrapper, "operationList")
|
||||
|
||||
for action in actions:
|
||||
@ -452,6 +463,11 @@ def timeout(registry, xml_parent, data):
|
||||
XML.SubElement(operation_list, fmt_str.format("Abort"))
|
||||
elif action == "fail":
|
||||
XML.SubElement(operation_list, fmt_str.format("Fail"))
|
||||
elif action == "abort-and-restart":
|
||||
abort_restart = XML.SubElement(
|
||||
operation_list, fmt_str.format("AbortAndRestart")
|
||||
)
|
||||
XML.SubElement(abort_restart, "maxRestarts").text = str(max_restarts)
|
||||
elif action == "write-description":
|
||||
write_description = XML.SubElement(
|
||||
operation_list, fmt_str.format("WriteDescription")
|
||||
|
@ -0,0 +1,3 @@
|
||||
- longName: 'Jenkins build timeout plugin'
|
||||
shortName: 'build-timeout'
|
||||
version: "1.17"
|
15
tests/wrappers/fixtures/timeout/version-1.17/timeout004.xml
Normal file
15
tests/wrappers/fixtures/timeout/version-1.17/timeout004.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.AbsoluteTimeOutStrategy">
|
||||
<timeoutMinutes>40</timeoutMinutes>
|
||||
</strategy>
|
||||
<operationList>
|
||||
<hudson.plugins.build__timeout.operations.AbortAndRestartOperation>
|
||||
<maxRestarts>2</maxRestarts>
|
||||
</hudson.plugins.build__timeout.operations.AbortAndRestartOperation>
|
||||
</operationList>
|
||||
</hudson.plugins.build__timeout.BuildTimeoutWrapper>
|
||||
</buildWrappers>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
wrappers:
|
||||
- timeout:
|
||||
abort-and-restart: true
|
||||
max-restarts: 2
|
||||
timeout: 40
|
||||
type: absolute
|
Loading…
Reference in New Issue
Block a user