diff options
-rw-r--r-- | jenkins_jobs/modules/project_multibranch.py | 26 | ||||
-rw-r--r-- | tests/multibranch/fixtures/scm_gerrit_full.xml | 6 | ||||
-rw-r--r-- | tests/multibranch/fixtures/scm_gerrit_full.yaml | 3 | ||||
-rw-r--r-- | tests/multibranch/fixtures/scm_gerrit_minimal.xml | 2 |
4 files changed, 34 insertions, 3 deletions
diff --git a/jenkins_jobs/modules/project_multibranch.py b/jenkins_jobs/modules/project_multibranch.py index 3761ddc1..93c5bc38 100644 --- a/jenkins_jobs/modules/project_multibranch.py +++ b/jenkins_jobs/modules/project_multibranch.py @@ -569,6 +569,13 @@ def gerrit_scm(xml_parent, data): (like to disable SCM triggering or to override the pipeline durability) (optional) Refer to :func:`~property_strategies <property_strategies>`. + :arg dict filter-checks: Enable the filtering by pending checks, allowing to + discover the changes that need validation only. This feature is using + the gerrit checks plugin. + (optional) + query-operator: Name of the query operator, supported values are: + 'SCHEME' or 'ID'. + query-string: Value of the query operator. Minimal Example: @@ -583,7 +590,10 @@ def gerrit_scm(xml_parent, data): source = XML.SubElement( xml_parent, "source", - {"class": "jenkins.plugins.gerrit.GerritSCMSource", "plugin": "gerrit"}, + { + "class": "jenkins.plugins.gerrit.GerritSCMSource", + "plugin": "gerrit-code-review", + }, ) source_mapping = [ ("", "id", "-".join(["gr", data.get("url", "")])), @@ -632,6 +642,20 @@ def gerrit_scm(xml_parent, data): if data.get("build-strategies", None): build_strategies(xml_parent, data) + # FilterChecks Trait + checks = data.get("filter-checks", None) + if checks: + checks_trait = XML.SubElement( + traits, "jenkins.plugins.gerrit.traits.FilterChecksTrait" + ) + checks_source_mapping = [ + ("query-operator", "queryOperator", None), + ("query-string", "queryString", None), + ] + helpers.convert_mapping_to_xml( + checks_trait, checks, checks_source_mapping, fail_required=True + ) + def git_scm(xml_parent, data): r"""Configure Git SCM diff --git a/tests/multibranch/fixtures/scm_gerrit_full.xml b/tests/multibranch/fixtures/scm_gerrit_full.xml index 04c59aec..02513673 100644 --- a/tests/multibranch/fixtures/scm_gerrit_full.xml +++ b/tests/multibranch/fixtures/scm_gerrit_full.xml @@ -31,7 +31,7 @@ <sources class="jenkins.branch.MultiBranchProject$BranchSourceList" plugin="branch-api"> <data> <jenkins.branch.BranchSource> - <source class="jenkins.plugins.gerrit.GerritSCMSource" plugin="gerrit"> + <source class="jenkins.plugins.gerrit.GerritSCMSource" plugin="gerrit-code-review"> <id>gr-https://review.gerrithub.io/johndoe/foo</id> <remote>https://review.gerrithub.io/johndoe/foo</remote> <credentialsId>secret</credentialsId> @@ -47,6 +47,10 @@ </jenkins.plugins.git.traits.RefSpecsSCMSourceTrait_-RefSpecTemplate> </templates> </jenkins.plugins.git.traits.RefSpecsSCMSourceTrait> + <jenkins.plugins.gerrit.traits.FilterChecksTrait> + <queryOperator>SCHEME</queryOperator> + <queryString>jenkins</queryString> + </jenkins.plugins.gerrit.traits.FilterChecksTrait> </traits> </source> <strategy class="jenkins.branch.DefaultBranchPropertyStrategy"> diff --git a/tests/multibranch/fixtures/scm_gerrit_full.yaml b/tests/multibranch/fixtures/scm_gerrit_full.yaml index 29fb7c86..1f325b6d 100644 --- a/tests/multibranch/fixtures/scm_gerrit_full.yaml +++ b/tests/multibranch/fixtures/scm_gerrit_full.yaml @@ -11,6 +11,9 @@ scm: all-branches: - suppress-scm-triggering: true - pipeline-branch-durability-override: max-survivability + filter-checks: + query-operator: 'SCHEME' + query-string: 'jenkins' build-strategies: - tags: ignore-tags-newer-than: 1 diff --git a/tests/multibranch/fixtures/scm_gerrit_minimal.xml b/tests/multibranch/fixtures/scm_gerrit_minimal.xml index 60959552..b29acd09 100644 --- a/tests/multibranch/fixtures/scm_gerrit_minimal.xml +++ b/tests/multibranch/fixtures/scm_gerrit_minimal.xml @@ -31,7 +31,7 @@ <sources class="jenkins.branch.MultiBranchProject$BranchSourceList" plugin="branch-api"> <data> <jenkins.branch.BranchSource> - <source class="jenkins.plugins.gerrit.GerritSCMSource" plugin="gerrit"> + <source class="jenkins.plugins.gerrit.GerritSCMSource" plugin="gerrit-code-review"> <id>gr-https://review.gerrithub.io/johndoe/foo</id> <remote>https://review.gerrithub.io/johndoe/foo</remote> <credentialsId/> |