diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py
index 0ffaac9d6..43f878cd0 100644
--- a/jenkins_jobs/modules/triggers.py
+++ b/jenkins_jobs/modules/triggers.py
@@ -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`).
diff --git a/tests/triggers/fixtures/gerrit004.xml b/tests/triggers/fixtures/gerrit004.xml
index 62e1483c9..151e43ba5 100644
--- a/tests/triggers/fixtures/gerrit004.xml
+++ b/tests/triggers/fixtures/gerrit004.xml
@@ -44,7 +44,11 @@
http://myhost/mytrigger
true
-
+
+ true
+ true
+ true
+
APRV
1
diff --git a/tests/triggers/fixtures/gerrit004.yaml b/tests/triggers/fixtures/gerrit004.yaml
index 84a45ce9c..6aaefdba6 100644
--- a/tests/triggers/fixtures/gerrit004.yaml
+++ b/tests/triggers/fixtures/gerrit004.yaml
@@ -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
diff --git a/tests/triggers/fixtures/gerrit007.xml b/tests/triggers/fixtures/gerrit007.xml
new file mode 100644
index 000000000..62e1483c9
--- /dev/null
+++ b/tests/triggers/fixtures/gerrit007.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+ PLAIN
+ test-project
+
+
+ PLAIN
+ master
+
+
+ PLAIN
+ stable
+
+
+
+
+ ANT
+ subdirectory/**
+
+
+
+
+ ANT
+ refactor-xy**
+
+
+
+
+
+ true
+ true
+ true
+ true
+
+ false
+ false
+ false
+ True
+ http://myhost/mytrigger
+ true
+
+
+
+ APRV
+ 1
+
+
+
+
+
+
+
+
+ my-server
+
+
+
diff --git a/tests/triggers/fixtures/gerrit007.yaml b/tests/triggers/fixtures/gerrit007.yaml
new file mode 100644
index 000000000..84a45ce9c
--- /dev/null
+++ b/tests/triggers/fixtures/gerrit007.yaml
@@ -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