Handle cancel-builds-on-update values from vars
The code assumes that the value of cancel-builds-on-update is a boolean. This fails when specifying the value of the param in a variable because when deep_formatter formats the data, booleans turn into strings. Also added tests for such case. Change-Id: Ib1ec3d5545091be550bfe023e49c7982372d5b55 Signed-off-by: Daniel Belenky <daniel.belenky@gmail.com>
This commit is contained in:
parent
2854caec9e
commit
3806c9c3d7
@ -1117,7 +1117,10 @@ def github_pull_request(registry, xml_parent, data):
|
||||
error_comment
|
||||
)
|
||||
|
||||
cancel_builds_on_update = data.get('cancel-builds-on-update', False)
|
||||
# When the value of cancel-builds-on-update comes from deep_formatter,
|
||||
# the value is of type 'str', otherwise the value is of type 'bool'
|
||||
cancel_builds_on_update = str(
|
||||
data.get('cancel-builds-on-update', False)).lower() == 'true'
|
||||
|
||||
# We want to have only one 'extensions' subelement, even if status
|
||||
# handling, comment handling and other extensions are enabled.
|
||||
|
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description><!-- Managed by Jenkins Job Builder --></description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
<properties/>
|
||||
<scm class="hudson.scm.NullSCM"/>
|
||||
<triggers class="vector">
|
||||
<org.jenkinsci.plugins.ghprb.GhprbTrigger>
|
||||
<adminlist/>
|
||||
<whitelist/>
|
||||
<orgslist/>
|
||||
<whiteListLabels/>
|
||||
<blackListLabels/>
|
||||
<excludedRegions/>
|
||||
<includedRegions/>
|
||||
<spec/>
|
||||
<allowMembersOfWhitelistedOrgsAsAdmin>false</allowMembersOfWhitelistedOrgsAsAdmin>
|
||||
<cron/>
|
||||
<triggerPhrase/>
|
||||
<skipBuildPhrase/>
|
||||
<onlyTriggerPhrase>false</onlyTriggerPhrase>
|
||||
<useGitHubHooks>false</useGitHubHooks>
|
||||
<permitAll>false</permitAll>
|
||||
<autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
|
||||
<extensions>
|
||||
<org.jenkinsci.plugins.ghprb.extensions.build.GhprbCancelBuildsOnUpdate/>
|
||||
</extensions>
|
||||
</org.jenkinsci.plugins.ghprb.GhprbTrigger>
|
||||
</triggers>
|
||||
<builders/>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
@ -0,0 +1,12 @@
|
||||
---
|
||||
- job-template:
|
||||
name: 'github-pull-request-variable-test-true'
|
||||
triggers:
|
||||
- github-pull-request:
|
||||
cancel-builds-on-update: '{test-var}'
|
||||
|
||||
- project:
|
||||
name: test-true
|
||||
test-var: true
|
||||
jobs:
|
||||
- 'github-pull-request-variable-test-true'
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<actions/>
|
||||
<description><!-- Managed by Jenkins Job Builder --></description>
|
||||
<keepDependencies>false</keepDependencies>
|
||||
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
|
||||
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
|
||||
<concurrentBuild>false</concurrentBuild>
|
||||
<canRoam>true</canRoam>
|
||||
<properties/>
|
||||
<scm class="hudson.scm.NullSCM"/>
|
||||
<triggers class="vector">
|
||||
<org.jenkinsci.plugins.ghprb.GhprbTrigger>
|
||||
<adminlist/>
|
||||
<whitelist/>
|
||||
<orgslist/>
|
||||
<whiteListLabels/>
|
||||
<blackListLabels/>
|
||||
<excludedRegions/>
|
||||
<includedRegions/>
|
||||
<spec/>
|
||||
<allowMembersOfWhitelistedOrgsAsAdmin>false</allowMembersOfWhitelistedOrgsAsAdmin>
|
||||
<cron/>
|
||||
<triggerPhrase/>
|
||||
<skipBuildPhrase/>
|
||||
<onlyTriggerPhrase>false</onlyTriggerPhrase>
|
||||
<useGitHubHooks>false</useGitHubHooks>
|
||||
<permitAll>false</permitAll>
|
||||
<autoCloseFailedPullRequests>false</autoCloseFailedPullRequests>
|
||||
</org.jenkinsci.plugins.ghprb.GhprbTrigger>
|
||||
</triggers>
|
||||
<builders/>
|
||||
<publishers/>
|
||||
<buildWrappers/>
|
||||
</project>
|
@ -0,0 +1,12 @@
|
||||
---
|
||||
- job-template:
|
||||
name: 'github-pull-request-variable-test-false'
|
||||
triggers:
|
||||
- github-pull-request:
|
||||
cancel-builds-on-update: '{test-var}'
|
||||
|
||||
- project:
|
||||
name: test-false
|
||||
test-var: false
|
||||
jobs:
|
||||
- 'github-pull-request-variable-test-false'
|
Loading…
x
Reference in New Issue
Block a user