Add support for new patchset-created exclude fields
New exclude features added to Gerrit Trigger plugin version 2.12.0. Exclude Features: - Drafts - Trivial Rebase - No Code Change This patch still supports the old trigger non-dict format yaml config: - patchset-created-event Using the old configuration (non-dict) works in the new Gerrit Trigger v2.12.0 as well as the previous versions. In addition the newer configuration (dict) format also works in old <2.12.0 and new >2.12.0 versions of Gerrit Trigger. Added additional unit tests to verify old and new formats working. Change-Id: I923b0be47085dc50da48f5ed271a13eae7e1dfa0 Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
This commit is contained in:
parent
520f3c5459
commit
7447292b57
@ -135,8 +135,8 @@ def build_gerrit_triggers(xml_parent, data):
|
||||
if isinstance(event, six.string_types):
|
||||
tag_name = available_simple_triggers.get(event)
|
||||
if event == 'patchset-uploaded-event':
|
||||
logger.warn("'%s' is deprecated. Use 'patchset-created-event'"
|
||||
"instead.", event)
|
||||
logger.warn("'%s' is deprecated. Use 'patchset-created-event' "
|
||||
"format instead.", event)
|
||||
|
||||
if not tag_name:
|
||||
known = ', '.join(available_simple_triggers.keys()
|
||||
@ -148,6 +148,18 @@ def build_gerrit_triggers(xml_parent, data):
|
||||
XML.SubElement(trigger_on_events,
|
||||
'%s.%s' % (tag_namespace, tag_name))
|
||||
else:
|
||||
if 'patchset-created-event' in event.keys():
|
||||
pce = event['patchset-created-event']
|
||||
pc = XML.SubElement(
|
||||
trigger_on_events,
|
||||
'%s.%s' % (tag_namespace, 'PluginPatchsetCreatedEvent'))
|
||||
XML.SubElement(pc, 'excludeDrafts').text = str(
|
||||
pce.get('exclude-drafts', False)).lower()
|
||||
XML.SubElement(pc, 'excludeTrivialRebase').text = str(
|
||||
pce.get('exclude-trivial-rebase', False)).lower()
|
||||
XML.SubElement(pc, 'excludeNoCodeChange').text = str(
|
||||
pce.get('exclude-no-code-change', False)).lower()
|
||||
|
||||
if 'comment-added-event' in event.keys():
|
||||
comment_added_event = event['comment-added-event']
|
||||
cadded = XML.SubElement(
|
||||
@ -200,7 +212,19 @@ def gerrit(parser, xml_parent, data):
|
||||
|
||||
:Trigger on:
|
||||
|
||||
* **patchset-created-event** -- Trigger upon patchset creation.
|
||||
* **patchset-created-event** (`dict`) -- Trigger upon patchset
|
||||
creation.
|
||||
|
||||
:Patchset created:
|
||||
* **exclude-drafts** (`bool`) -- exclude drafts (Default: False)
|
||||
* **exclude-trivial-rebase** (`bool`) -- exclude trivial rebase
|
||||
(Default: False)
|
||||
* **exclude-no-code-change** (`bool`) -- exclude no code change
|
||||
(Default: False)
|
||||
|
||||
Exclude drafts|trivial-rebase|no-code-change needs
|
||||
Gerrit Trigger v2.12.0
|
||||
|
||||
* **patchset-uploaded-event** -- Trigger upon patchset creation
|
||||
(this is a alias for `patchset-created-event`).
|
||||
|
||||
|
@ -44,7 +44,11 @@
|
||||
<triggerConfigURL>http://myhost/mytrigger</triggerConfigURL>
|
||||
<allowTriggeringUnreviewedPatches>true</allowTriggeringUnreviewedPatches>
|
||||
<triggerOnEvents>
|
||||
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginPatchsetCreatedEvent/>
|
||||
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginPatchsetCreatedEvent>
|
||||
<excludeDrafts>true</excludeDrafts>
|
||||
<excludeTrivialRebase>true</excludeTrivialRebase>
|
||||
<excludeNoCodeChange>true</excludeNoCodeChange>
|
||||
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginPatchsetCreatedEvent>
|
||||
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginCommentAddedEvent>
|
||||
<verdictCategory>APRV</verdictCategory>
|
||||
<commentAddedTriggerApprovalValue>1</commentAddedTriggerApprovalValue>
|
||||
|
@ -1,7 +1,10 @@
|
||||
triggers:
|
||||
- gerrit:
|
||||
trigger-on:
|
||||
- patchset-created-event
|
||||
- patchset-created-event:
|
||||
exclude-drafts: true
|
||||
exclude-trivial-rebase: true
|
||||
exclude-no-code-change: true
|
||||
- comment-added-event:
|
||||
approval-category: 'APRV'
|
||||
approval-value: 1
|
||||
|
62
tests/triggers/fixtures/gerrit007.xml
Normal file
62
tests/triggers/fixtures/gerrit007.xml
Normal file
@ -0,0 +1,62 @@
|
||||
<?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>PLAIN</compareType>
|
||||
<pattern>master</pattern>
|
||||
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
|
||||
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Branch>
|
||||
<compareType>PLAIN</compareType>
|
||||
<pattern>stable</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>
|
||||
<topics>
|
||||
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Topic>
|
||||
<compareType>ANT</compareType>
|
||||
<pattern>refactor-xy**</pattern>
|
||||
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.data.Topic>
|
||||
</topics>
|
||||
</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>true</allowTriggeringUnreviewedPatches>
|
||||
<triggerOnEvents>
|
||||
<com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.events.PluginPatchsetCreatedEvent/>
|
||||
<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/>
|
||||
<customUrl/>
|
||||
<serverName>my-server</serverName>
|
||||
</com.sonyericsson.hudson.plugins.gerrit.trigger.hudsontrigger.GerritTrigger>
|
||||
</triggers>
|
||||
</project>
|
33
tests/triggers/fixtures/gerrit007.yaml
Normal file
33
tests/triggers/fixtures/gerrit007.yaml
Normal file
@ -0,0 +1,33 @@
|
||||
triggers:
|
||||
- gerrit:
|
||||
trigger-on:
|
||||
- patchset-created-event
|
||||
- comment-added-event:
|
||||
approval-category: 'APRV'
|
||||
approval-value: 1
|
||||
projects:
|
||||
- project-compare-type: 'PLAIN'
|
||||
project-pattern: 'test-project'
|
||||
branches:
|
||||
- branch-compare-type: 'PLAIN'
|
||||
branch-pattern: 'master'
|
||||
- branch-compare-type: 'PLAIN'
|
||||
branch-pattern: 'stable'
|
||||
file-paths:
|
||||
- compare-type: ANT
|
||||
pattern: subdirectory/**
|
||||
topics:
|
||||
- compare-type: ANT
|
||||
pattern: refactor-xy**
|
||||
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
|
||||
trigger-for-unreviewed-patches: true
|
||||
server-name: my-server
|
Loading…
Reference in New Issue
Block a user