Handle string skip-vote parameters in gerrit trigger

Prior to this commit, the code assumes that the parameters given in the
YAML will parse as Python bools.  This fails when, for example, the
string "false" is given.

Change-Id: Ia7d0f5954929d13acc268f878ce992808b258a12
Story: 2001466
Task: 6183
This commit is contained in:
Daniel Watkins 2018-05-30 17:00:54 -04:00
parent 307c09cff3
commit 1d90d0d5ba
3 changed files with 83 additions and 4 deletions

View File

@ -204,10 +204,8 @@ def build_gerrit_skip_votes(xml_parent, data):
skip_vote_node = XML.SubElement(xml_parent, 'skipVote')
skip_vote = data.get('skip-vote', {})
for result_kind, tag_name in outcomes:
if skip_vote.get(result_kind, False):
XML.SubElement(skip_vote_node, tag_name).text = 'true'
else:
XML.SubElement(skip_vote_node, tag_name).text = 'false'
setting = skip_vote.get(result_kind, False)
XML.SubElement(skip_vote_node, tag_name).text = str(setting).lower()
def gerrit(registry, xml_parent, data):

View File

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<triggers class="vector">
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
<spec/>
<gerritProjects>
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
<compareType>PLAIN</compareType>
<pattern>test-project</pattern>
<branches>
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
<compareType>ANT</compareType>
<pattern>**</pattern>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
</branches>
<filePaths>
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
<compareType>ANT</compareType>
<pattern>subdirectory/**</pattern>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.FilePath>
</filePaths>
<disableStrictForbiddenFileVerification>false</disableStrictForbiddenFileVerification>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
</gerritProjects>
<skipVote>
<onSuccessful>false</onSuccessful>
<onFailed>false</onFailed>
<onUnstable>false</onUnstable>
<onNotBuilt>false</onNotBuilt>
</skipVote>
<silentMode>false</silentMode>
<silentStartMode>false</silentStartMode>
<escapeQuotes>false</escapeQuotes>
<noNameAndEmailParameters>false</noNameAndEmailParameters>
<readableMessage>false</readableMessage>
<dependencyJobsNames/>
<notificationLevel/>
<dynamicTriggerConfiguration>True</dynamicTriggerConfiguration>
<triggerConfigURL>http://myhost/mytrigger</triggerConfigURL>
<triggerInformationAction/>
<allowTriggeringUnreviewedPatches>false</allowTriggeringUnreviewedPatches>
<triggerOnEvents>
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedEvent>
<verdictCategory>APRV</verdictCategory>
<commentAddedTriggerApprovalValue>1</commentAddedTriggerApprovalValue>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedEvent>
</triggerOnEvents>
<buildStartMessage/>
<buildFailureMessage/>
<buildSuccessfulMessage/>
<buildUnstableMessage/>
<buildNotBuiltMessage/>
<buildUnsuccessfulFilepath/>
<customUrl/>
<serverName>__ANY__</serverName>
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
</triggers>
</project>

View File

@ -0,0 +1,23 @@
triggers:
- gerrit:
trigger-on-comment-added-event: true
trigger-approval-category: 'APRV'
trigger-approval-value: 1
projects:
- project-compare-type: 'PLAIN'
project-pattern: 'test-project'
branch-compare-type: 'ANT'
branch-pattern: '**'
file-paths:
- compare-type: ANT
pattern: subdirectory/**
skip-vote:
successful: 'false'
failed: 'false'
unstable: 'false'
notbuilt: 'false'
silent: false
escape-quotes: false
no-name-and-email: false
dynamic-trigger-enabled: true
dynamic-trigger-url: http://myhost/mytrigger