From 440acd0fa1b01bc6328dba2fe8d74ffb2a85a9d9 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Thu, 29 Oct 2015 20:45:10 -0400 Subject: [PATCH] Add support for disable-strict-forbidden-file-verification Enabling this option will allow an event to trigger a build if the event contains BOTH one or more wanted file paths AND one or more forbidden file paths. In other words, with this option, the build will not get triggered if the change contains only forbidden files, otherwise it will get triggered. Support for this was added in Plugin Version 2.16.0. Change-Id: I860b076c2393909012c3ac9821559c9e8c9f7e28 --- jenkins_jobs/modules/triggers.py | 14 ++++++++++++++ tests/jsonparser/fixtures/complete001.xml | 1 + tests/triggers/fixtures/gerrit001.xml | 1 + tests/triggers/fixtures/gerrit002.xml | 1 + tests/triggers/fixtures/gerrit003.xml | 2 ++ tests/triggers/fixtures/gerrit004.xml | 1 + tests/triggers/fixtures/gerrit005.xml | 1 + tests/triggers/fixtures/gerrit006.xml | 1 + tests/triggers/fixtures/gerrit007.xml | 1 + tests/triggers/fixtures/gerrit008.xml | 1 + tests/triggers/fixtures/gerrit008.yaml | 1 + tests/yamlparser/fixtures/complete001.xml | 1 + 12 files changed, 26 insertions(+) diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py index e69d60dca..998b7b612 100644 --- a/jenkins_jobs/modules/triggers.py +++ b/jenkins_jobs/modules/triggers.py @@ -367,6 +367,15 @@ def gerrit(parser, xml_parent, data): * **pattern** (`str`) -- Topic name pattern to match + * **disable-strict-forbidden-file-verification** (`bool`) -- + Enabling this option will allow an event to trigger a + build if the event contains BOTH one or more wanted file + paths AND one or more forbidden file paths. In other + words, with this option, the build will not get + triggered if the change contains only forbidden files, + otherwise it will get triggered. Requires plugin + version >= 2.16.0 (default false) + :arg dict skip-vote: map of build outcomes for which Jenkins must skip vote. Requires Gerrit Trigger Plugin version >= 2.7.0 @@ -521,6 +530,11 @@ def gerrit(parser, xml_parent, data): 'PLAIN')) XML.SubElement(topic_tag, 'pattern').text = topic['pattern'] + XML.SubElement(gproj, + 'disableStrictForbiddenFileVerification').text = str( + project.get('disable-strict-forbidden-file-verification', + False)).lower() + build_gerrit_skip_votes(gtrig, data) XML.SubElement(gtrig, 'silentMode').text = str( data.get('silent', False)).lower() diff --git a/tests/jsonparser/fixtures/complete001.xml b/tests/jsonparser/fixtures/complete001.xml index f90b2f59f..506a86968 100644 --- a/tests/jsonparser/fixtures/complete001.xml +++ b/tests/jsonparser/fixtures/complete001.xml @@ -62,6 +62,7 @@ ** + false diff --git a/tests/triggers/fixtures/gerrit001.xml b/tests/triggers/fixtures/gerrit001.xml index d26fe1b7d..5d769f22c 100644 --- a/tests/triggers/fixtures/gerrit001.xml +++ b/tests/triggers/fixtures/gerrit001.xml @@ -19,6 +19,7 @@ subdirectory/** + false diff --git a/tests/triggers/fixtures/gerrit002.xml b/tests/triggers/fixtures/gerrit002.xml index 5ed874188..9e6879007 100644 --- a/tests/triggers/fixtures/gerrit002.xml +++ b/tests/triggers/fixtures/gerrit002.xml @@ -23,6 +23,7 @@ subdirectory/** + false diff --git a/tests/triggers/fixtures/gerrit003.xml b/tests/triggers/fixtures/gerrit003.xml index 30f0bbf3e..8e3549f13 100644 --- a/tests/triggers/fixtures/gerrit003.xml +++ b/tests/triggers/fixtures/gerrit003.xml @@ -19,6 +19,7 @@ subdirectory/** + false PLAIN @@ -39,6 +40,7 @@ subdirectory/** + false diff --git a/tests/triggers/fixtures/gerrit004.xml b/tests/triggers/fixtures/gerrit004.xml index 31e7138ec..d4d78e90a 100644 --- a/tests/triggers/fixtures/gerrit004.xml +++ b/tests/triggers/fixtures/gerrit004.xml @@ -29,6 +29,7 @@ refactor-xy** + false diff --git a/tests/triggers/fixtures/gerrit005.xml b/tests/triggers/fixtures/gerrit005.xml index dfd673114..67ea3c43a 100644 --- a/tests/triggers/fixtures/gerrit005.xml +++ b/tests/triggers/fixtures/gerrit005.xml @@ -19,6 +19,7 @@ subdirectory/** + false diff --git a/tests/triggers/fixtures/gerrit006.xml b/tests/triggers/fixtures/gerrit006.xml index dd41f62c3..ae693508b 100644 --- a/tests/triggers/fixtures/gerrit006.xml +++ b/tests/triggers/fixtures/gerrit006.xml @@ -19,6 +19,7 @@ subdirectory/** + false diff --git a/tests/triggers/fixtures/gerrit007.xml b/tests/triggers/fixtures/gerrit007.xml index e670f5a3b..335094b6e 100644 --- a/tests/triggers/fixtures/gerrit007.xml +++ b/tests/triggers/fixtures/gerrit007.xml @@ -29,6 +29,7 @@ refactor-xy** + false diff --git a/tests/triggers/fixtures/gerrit008.xml b/tests/triggers/fixtures/gerrit008.xml index 35639fdca..4b9342de9 100644 --- a/tests/triggers/fixtures/gerrit008.xml +++ b/tests/triggers/fixtures/gerrit008.xml @@ -35,6 +35,7 @@ refactor-xy** + true diff --git a/tests/triggers/fixtures/gerrit008.yaml b/tests/triggers/fixtures/gerrit008.yaml index fd951afcc..38897f372 100644 --- a/tests/triggers/fixtures/gerrit008.yaml +++ b/tests/triggers/fixtures/gerrit008.yaml @@ -21,6 +21,7 @@ triggers: forbidden-file-paths: - compare-type: ANT pattern: subdirectory/** + disable-strict-forbidden-file-verification: true topics: - compare-type: ANT pattern: refactor-xy** diff --git a/tests/yamlparser/fixtures/complete001.xml b/tests/yamlparser/fixtures/complete001.xml index a30b25aff..a3fabd2a6 100644 --- a/tests/yamlparser/fixtures/complete001.xml +++ b/tests/yamlparser/fixtures/complete001.xml @@ -62,6 +62,7 @@ ** + false