Fix timeout wrapper version detection

If, for whatever reason, the version of the build-timeout
plugin can not be detected, assume that we use a newer version (>= 1.14).
Version 1.14 is already ~ 2 1/2 years old so this is a sane assumption.
Also adjust fixtures to use the newer plugin version xml output.

Change-Id: I86295933d0c3247f55d0114473fc9c8f8feb7441
Signed-off-by: Bertrand Roussel <broussel@sierrawireless.com>
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
This commit is contained in:
Thomas Bechtold 2016-10-18 07:56:57 +02:00 committed by Bertrand Roussel
parent 0b5ed0345a
commit ecf3933dc2
12 changed files with 92 additions and 71 deletions

View File

@ -312,14 +312,19 @@ def timeout(registry, xml_parent, data):
prefix = 'hudson.plugins.build__timeout.'
twrapper = XML.SubElement(xml_parent, prefix + 'BuildTimeoutWrapper')
plugin_info = registry.get_plugin_info(
"Jenkins build timeout plugin")
version = pkg_resources.parse_version(plugin_info.get("version", "0"))
plugin_info = registry.get_plugin_info("Build Timeout")
if "version" not in plugin_info:
plugin_info = registry.get_plugin_info("Jenkins build timeout plugin")
version = plugin_info.get("version", None)
if version:
version = pkg_resources.parse_version(version)
valid_strategies = ['absolute', 'no-activity', 'likely-stuck', 'elastic',
'deadline']
if version >= pkg_resources.parse_version("1.14"):
# NOTE(toabctl): if we don't know the version assume that we
# use a newer version of the plugin
if not version or version >= pkg_resources.parse_version("1.14"):
strategy = data.get('type', 'absolute')
if strategy not in valid_strategies:
InvalidAttributeError('type', strategy, valid_strategies)

View File

@ -109,12 +109,14 @@ print(&quot;Doing something cool with python&quot;)
<publishers/>
<buildWrappers>
<hudson.plugins.build__timeout.BuildTimeoutWrapper>
<timeoutMinutes>3</timeoutMinutes>
<failBuild>true</failBuild>
<writingDescription>false</writingDescription>
<timeoutPercentage>150</timeoutPercentage>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
<timeoutType>elastic</timeoutType>
<strategy class="hudson.plugins.build_timeout.impl.ElasticTimeOutStrategy">
<timeoutPercentage>150</timeoutPercentage>
<numberOfBuilds>0</numberOfBuilds>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
</strategy>
<operationList>
<hudson.plugins.build__timeout.operations.FailOperation/>
</operationList>
</hudson.plugins.build__timeout.BuildTimeoutWrapper>
<org.jenkinsci.plugins.preSCMbuildstep.PreSCMBuildStepsWrapper>
<buildSteps>

View File

@ -2,13 +2,13 @@
<project>
<buildWrappers>
<hudson.plugins.build__timeout.BuildTimeoutWrapper>
<timeoutMinutes>90</timeoutMinutes>
<strategy class="hudson.plugins.build_timeout.impl.AbsoluteTimeOutStrategy">
<timeoutMinutes>90</timeoutMinutes>
</strategy>
<operationList>
<hudson.plugins.build__timeout.operations.FailOperation/>
</operationList>
<timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
<failBuild>true</failBuild>
<writingDescription>false</writingDescription>
<timeoutPercentage>0</timeoutPercentage>
<timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
<timeoutType>absolute</timeoutType>
</hudson.plugins.build__timeout.BuildTimeoutWrapper>
</buildWrappers>
</project>

View File

@ -2,12 +2,12 @@
<project>
<buildWrappers>
<hudson.plugins.build__timeout.BuildTimeoutWrapper>
<timeoutMinutes>3</timeoutMinutes>
<failBuild>false</failBuild>
<writingDescription>false</writingDescription>
<timeoutPercentage>0</timeoutPercentage>
<timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
<timeoutType>likelyStuck</timeoutType>
<strategy class="hudson.plugins.build_timeout.impl.LikelyStuckTimeOutStrategy">
<timeoutMinutes>3</timeoutMinutes>
</strategy>
<operationList>
<hudson.plugins.build__timeout.operations.AbortOperation/>
</operationList>
</hudson.plugins.build__timeout.BuildTimeoutWrapper>
</buildWrappers>
</project>
</project>

View File

@ -2,13 +2,15 @@
<project>
<buildWrappers>
<hudson.plugins.build__timeout.BuildTimeoutWrapper>
<timeoutMinutes>3</timeoutMinutes>
<strategy class="hudson.plugins.build_timeout.impl.ElasticTimeOutStrategy">
<timeoutPercentage>150</timeoutPercentage>
<numberOfBuilds>0</numberOfBuilds>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
</strategy>
<operationList>
<hudson.plugins.build__timeout.operations.FailOperation/>
</operationList>
<timeoutEnvVar>BUILD_TIMEOUT</timeoutEnvVar>
<failBuild>true</failBuild>
<writingDescription>false</writingDescription>
<timeoutPercentage>150</timeoutPercentage>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
<timeoutType>elastic</timeoutType>
</hudson.plugins.build__timeout.BuildTimeoutWrapper>
</buildWrappers>
</project>

View File

@ -112,12 +112,14 @@ print(&quot;Doing something cool with python&quot;)
<publishers/>
<buildWrappers>
<hudson.plugins.build__timeout.BuildTimeoutWrapper>
<timeoutMinutes>3</timeoutMinutes>
<failBuild>true</failBuild>
<writingDescription>false</writingDescription>
<timeoutPercentage>150</timeoutPercentage>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
<timeoutType>elastic</timeoutType>
<strategy class="hudson.plugins.build_timeout.impl.ElasticTimeOutStrategy">
<timeoutPercentage>150</timeoutPercentage>
<numberOfBuilds>0</numberOfBuilds>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
</strategy>
<operationList>
<hudson.plugins.build__timeout.operations.FailOperation/>
</operationList>
</hudson.plugins.build__timeout.BuildTimeoutWrapper>
<org.jenkinsci.plugins.preSCMbuildstep.PreSCMBuildStepsWrapper>
<buildSteps>

View File

@ -23,12 +23,14 @@
<publishers/>
<buildWrappers>
<hudson.plugins.build__timeout.BuildTimeoutWrapper>
<timeoutMinutes>3</timeoutMinutes>
<failBuild>true</failBuild>
<writingDescription>false</writingDescription>
<timeoutPercentage>150</timeoutPercentage>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
<timeoutType>elastic</timeoutType>
<strategy class="hudson.plugins.build_timeout.impl.ElasticTimeOutStrategy">
<timeoutPercentage>150</timeoutPercentage>
<numberOfBuilds>0</numberOfBuilds>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
</strategy>
<operationList>
<hudson.plugins.build__timeout.operations.FailOperation/>
</operationList>
</hudson.plugins.build__timeout.BuildTimeoutWrapper>
<org.jenkinsci.plugins.preSCMbuildstep.PreSCMBuildStepsWrapper>
<buildSteps>

View File

@ -23,12 +23,14 @@
<publishers/>
<buildWrappers>
<hudson.plugins.build__timeout.BuildTimeoutWrapper>
<timeoutMinutes>3</timeoutMinutes>
<failBuild>true</failBuild>
<writingDescription>false</writingDescription>
<timeoutPercentage>150</timeoutPercentage>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
<timeoutType>elastic</timeoutType>
<strategy class="hudson.plugins.build_timeout.impl.ElasticTimeOutStrategy">
<timeoutPercentage>150</timeoutPercentage>
<numberOfBuilds>0</numberOfBuilds>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
</strategy>
<operationList>
<hudson.plugins.build__timeout.operations.FailOperation/>
</operationList>
</hudson.plugins.build__timeout.BuildTimeoutWrapper>
<org.jenkinsci.plugins.preSCMbuildstep.PreSCMBuildStepsWrapper>
<buildSteps>

View File

@ -33,12 +33,14 @@ echo &quot;Doing somethiung cool&quot;
<publishers/>
<buildWrappers>
<hudson.plugins.build__timeout.BuildTimeoutWrapper>
<timeoutMinutes>3</timeoutMinutes>
<failBuild>true</failBuild>
<writingDescription>false</writingDescription>
<timeoutPercentage>150</timeoutPercentage>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
<timeoutType>elastic</timeoutType>
<strategy class="hudson.plugins.build_timeout.impl.ElasticTimeOutStrategy">
<timeoutPercentage>150</timeoutPercentage>
<numberOfBuilds>0</numberOfBuilds>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
</strategy>
<operationList>
<hudson.plugins.build__timeout.operations.FailOperation/>
</operationList>
</hudson.plugins.build__timeout.BuildTimeoutWrapper>
</buildWrappers>
</project>

View File

@ -30,12 +30,14 @@ VERSION=&quot;1.1&quot;
<publishers/>
<buildWrappers>
<hudson.plugins.build__timeout.BuildTimeoutWrapper>
<timeoutMinutes>3</timeoutMinutes>
<failBuild>true</failBuild>
<writingDescription>false</writingDescription>
<timeoutPercentage>150</timeoutPercentage>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
<timeoutType>elastic</timeoutType>
<strategy class="hudson.plugins.build_timeout.impl.ElasticTimeOutStrategy">
<timeoutPercentage>150</timeoutPercentage>
<numberOfBuilds>0</numberOfBuilds>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
</strategy>
<operationList>
<hudson.plugins.build__timeout.operations.FailOperation/>
</operationList>
</hudson.plugins.build__timeout.BuildTimeoutWrapper>
</buildWrappers>
</project>

View File

@ -30,12 +30,14 @@ VERSION=&quot;1.2&quot;
<publishers/>
<buildWrappers>
<hudson.plugins.build__timeout.BuildTimeoutWrapper>
<timeoutMinutes>3</timeoutMinutes>
<failBuild>true</failBuild>
<writingDescription>false</writingDescription>
<timeoutPercentage>150</timeoutPercentage>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
<timeoutType>elastic</timeoutType>
<strategy class="hudson.plugins.build_timeout.impl.ElasticTimeOutStrategy">
<timeoutPercentage>150</timeoutPercentage>
<numberOfBuilds>0</numberOfBuilds>
<timeoutMinutesElasticDefault>90</timeoutMinutesElasticDefault>
</strategy>
<operationList>
<hudson.plugins.build__timeout.operations.FailOperation/>
</operationList>
</hudson.plugins.build__timeout.BuildTimeoutWrapper>
<org.jenkinsci.plugins.preSCMbuildstep.PreSCMBuildStepsWrapper>
<buildSteps>

View File

@ -13,12 +13,12 @@
<publishers/>
<buildWrappers>
<hudson.plugins.build__timeout.BuildTimeoutWrapper>
<timeoutMinutes>180</timeoutMinutes>
<failBuild>true</failBuild>
<writingDescription>false</writingDescription>
<timeoutPercentage>0</timeoutPercentage>
<timeoutMinutesElasticDefault>3</timeoutMinutesElasticDefault>
<timeoutType>absolute</timeoutType>
<strategy class="hudson.plugins.build_timeout.impl.AbsoluteTimeOutStrategy">
<timeoutMinutes>180</timeoutMinutes>
</strategy>
<operationList>
<hudson.plugins.build__timeout.operations.FailOperation/>
</operationList>
</hudson.plugins.build__timeout.BuildTimeoutWrapper>
<hudson.plugins.timestamper.TimestamperBuildWrapper/>
</buildWrappers>