Add support for Gerrit Trigger Comment Contains Expression
Change-Id: I229c7fc2fac540a6fe3209221ca01dcf6dd068df Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
This commit is contained in:
parent
3b3bb47a98
commit
58b9fd9ca6
@ -137,23 +137,37 @@ def build_gerrit_triggers(xml_parent, data):
|
||||
if event == 'patchset-uploaded-event':
|
||||
logger.warn("'%s' is deprecated. Use 'patchset-created-event'"
|
||||
"instead.", event)
|
||||
|
||||
if not tag_name:
|
||||
known = ', '.join(available_simple_triggers.keys()
|
||||
+ ['comment-added-event'])
|
||||
+ ['comment-added-event',
|
||||
'comment-added-contains-event'])
|
||||
msg = ("The event '%s' under 'trigger-on' is not one of the "
|
||||
"known: %s.") % (event, known)
|
||||
raise JenkinsJobsException(msg)
|
||||
XML.SubElement(trigger_on_events,
|
||||
'%s.%s' % (tag_namespace, tag_name))
|
||||
else:
|
||||
comment_added_event = event['comment-added-event']
|
||||
cadded = XML.SubElement(
|
||||
trigger_on_events,
|
||||
'%s.%s' % (tag_namespace, 'PluginCommentAddedEvent'))
|
||||
XML.SubElement(cadded, 'verdictCategory').text = \
|
||||
comment_added_event['approval-category']
|
||||
XML.SubElement(cadded, 'commentAddedTriggerApprovalValue').text = \
|
||||
str(comment_added_event['approval-value'])
|
||||
if 'comment-added-event' in event.keys():
|
||||
comment_added_event = event['comment-added-event']
|
||||
cadded = XML.SubElement(
|
||||
trigger_on_events,
|
||||
'%s.%s' % (tag_namespace, 'PluginCommentAddedEvent'))
|
||||
XML.SubElement(cadded, 'verdictCategory').text = \
|
||||
comment_added_event['approval-category']
|
||||
XML.SubElement(
|
||||
cadded,
|
||||
'commentAddedTriggerApprovalValue').text = \
|
||||
str(comment_added_event['approval-value'])
|
||||
|
||||
if 'comment-added-contains-event' in event.keys():
|
||||
comment_added_event = event['comment-added-contains-event']
|
||||
caddedc = XML.SubElement(
|
||||
trigger_on_events,
|
||||
'%s.%s' % (tag_namespace,
|
||||
'PluginCommentAddedContainsEvent'))
|
||||
XML.SubElement(caddedc, 'commentAddedCommentContains').text = \
|
||||
comment_added_event['comment-contains-value']
|
||||
|
||||
|
||||
def build_gerrit_skip_votes(xml_parent, data):
|
||||
@ -209,6 +223,14 @@ def gerrit(parser, xml_parent, data):
|
||||
access-control.html#categories>`_
|
||||
|
||||
* **approval-value** -- Approval value for the comment added.
|
||||
* **comment-added-contains-event** (`dict`) -- Trigger on comment
|
||||
added contains
|
||||
Regular Expression.
|
||||
|
||||
:Comment added contains:
|
||||
* **comment-contains-value** (`str`) -- Comment contains
|
||||
Regular Expression
|
||||
value.
|
||||
|
||||
:arg bool trigger-on-patchset-uploaded-event: Trigger on patchset upload.
|
||||
|
||||
|
50
tests/triggers/fixtures/gerrit006.xml
Normal file
50
tests/triggers/fixtures/gerrit006.xml
Normal file
@ -0,0 +1,50 @@
|
||||
<?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>
|
||||
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.GerritProject>
|
||||
</gerritProjects>
|
||||
<skipVote>
|
||||
<onSuccessful>true</onSuccessful>
|
||||
<onFailed>true</onFailed>
|
||||
<onUnstable>true</onUnstable>
|
||||
<onNotBuilt>true</onNotBuilt>
|
||||
</skipVote>
|
||||
<silentMode>false</silentMode>
|
||||
<escapeQuotes>false</escapeQuotes>
|
||||
<noNameAndEmailParameters>false</noNameAndEmailParameters>
|
||||
<dynamicTriggerConfiguration>True</dynamicTriggerConfiguration>
|
||||
<triggerConfigURL>http://myhost/mytrigger</triggerConfigURL>
|
||||
<allowTriggeringUnreviewedPatches>false</allowTriggeringUnreviewedPatches>
|
||||
<triggerOnEvents>
|
||||
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
|
||||
<commentAddedCommentContains>recheck</commentAddedCommentContains>
|
||||
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedContainsEvent>
|
||||
</triggerOnEvents>
|
||||
<buildStartMessage/>
|
||||
<buildFailureMessage/>
|
||||
<buildSuccessfulMessage/>
|
||||
<buildUnstableMessage/>
|
||||
<buildNotBuiltMessage/>
|
||||
<customUrl/>
|
||||
<serverName>__ANY__</serverName>
|
||||
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
|
||||
</triggers>
|
||||
</project>
|
23
tests/triggers/fixtures/gerrit006.yaml
Normal file
23
tests/triggers/fixtures/gerrit006.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
triggers:
|
||||
- gerrit:
|
||||
trigger-on:
|
||||
- comment-added-contains-event:
|
||||
comment-contains-value: 'recheck'
|
||||
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: true
|
||||
failed: true
|
||||
unstable: true
|
||||
notbuilt: true
|
||||
silent: false
|
||||
escape-quotes: false
|
||||
no-name-and-email: false
|
||||
dynamic-trigger-enabled: true
|
||||
dynamic-trigger-url: http://myhost/mytrigger
|
Loading…
Reference in New Issue
Block a user