diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py
index 9b34e489f..338971374 100644
--- a/jenkins_jobs/modules/triggers.py
+++ b/jenkins_jobs/modules/triggers.py
@@ -1671,8 +1671,14 @@ def gitlab(registry, xml_parent, data):
(default [])
:arg list exclude-branches: Defined list of branches to exclude
(default [])
+ :arg str source-branch-regex: Regular expression to select branches
:arg str target-branch-regex: Regular expression to select branches
:arg str secret-token: Secret token for build trigger
+ :arg dict merge-request-label-filter-config: If used allow merge requests
+ filtering by labels
+
+ :Options: * **include** (`str`) Run for specified labels.
+ * **exclude** (`str`) Do not run for specified labels.
.. _`branch filter type`:
@@ -1692,7 +1698,7 @@ def gitlab(registry, xml_parent, data):
The target branch regex allows you to limit the
execution of this job to certain branches. Any
branch matching the specified pattern in
- **target-branch-regex** triggers the job. No
+ **target-branch-regex** and **source-branch-regex** triggers the job. No
filtering is performed if the field is left empty.
================== ====================================================
@@ -1772,6 +1778,7 @@ def gitlab(registry, xml_parent, data):
("accept-merge-request-on-success", "acceptMergeRequestOnSuccess", False),
("add-ci-message", "addCiMessage", False),
("allow-all-branches", "allowAllBranches", False),
+ ("source-branch-regex", "sourceBranchRegex", ""),
("target-branch-regex", "targetBranchRegex", ""),
("secret-token", "secretToken", ""),
]
@@ -1788,6 +1795,19 @@ def gitlab(registry, xml_parent, data):
optional_mapping = (("pending-build-name", "pendingBuildName", None),)
helpers.convert_mapping_to_xml(gitlab, data, optional_mapping, fail_required=False)
+ if data.get("merge-request-label-filter-config"):
+ merge_request_filter = XML.SubElement(gitlab, "mergeRequestLabelFilterConfig")
+ merge_mapping = [
+ ("include", "include", ""),
+ ("exclude", "exclude", ""),
+ ]
+ helpers.convert_mapping_to_xml(
+ merge_request_filter,
+ data.get("merge-request-label-filter-config", ""),
+ merge_mapping,
+ fail_required=False,
+ )
+
def gogs(registry, xml_parent, data):
"""yaml: gogs
diff --git a/tests/triggers/fixtures/gitlab001.xml b/tests/triggers/fixtures/gitlab001.xml
index 7a3b6d489..d72c78b74 100644
--- a/tests/triggers/fixtures/gitlab001.xml
+++ b/tests/triggers/fixtures/gitlab001.xml
@@ -21,6 +21,7 @@
false
true
true
+
master, master2, local-test
diff --git a/tests/triggers/fixtures/gitlab002.xml b/tests/triggers/fixtures/gitlab002.xml
index add8cf68c..4fc6577b0 100644
--- a/tests/triggers/fixtures/gitlab002.xml
+++ b/tests/triggers/fixtures/gitlab002.xml
@@ -21,6 +21,7 @@
false
false
false
+
master
diff --git a/tests/triggers/fixtures/gitlab003.xml b/tests/triggers/fixtures/gitlab003.xml
index 52d2b24b9..9b3a90d00 100644
--- a/tests/triggers/fixtures/gitlab003.xml
+++ b/tests/triggers/fixtures/gitlab003.xml
@@ -21,6 +21,7 @@
false
false
false
+
master
diff --git a/tests/triggers/fixtures/gitlab004.xml b/tests/triggers/fixtures/gitlab004.xml
index c12c01b88..bde1b4271 100644
--- a/tests/triggers/fixtures/gitlab004.xml
+++ b/tests/triggers/fixtures/gitlab004.xml
@@ -21,6 +21,7 @@
false
true
true
+
master, master2, local-test
diff --git a/tests/triggers/fixtures/gitlab005.xml b/tests/triggers/fixtures/gitlab005.xml
index 74901697e..1028f6e7b 100644
--- a/tests/triggers/fixtures/gitlab005.xml
+++ b/tests/triggers/fixtures/gitlab005.xml
@@ -21,6 +21,7 @@
false
false
false
+
diff --git a/tests/triggers/fixtures/gitlab006.xml b/tests/triggers/fixtures/gitlab006.xml
index 0d3e860fe..b341ce919 100644
--- a/tests/triggers/fixtures/gitlab006.xml
+++ b/tests/triggers/fixtures/gitlab006.xml
@@ -21,6 +21,7 @@
true
true
false
+
(.*debug.*|.*release.*)
secret-build-token
include1, include2
diff --git a/tests/triggers/fixtures/gitlab007.xml b/tests/triggers/fixtures/gitlab007.xml
index 25eab8ba5..fc7072d6a 100644
--- a/tests/triggers/fixtures/gitlab007.xml
+++ b/tests/triggers/fixtures/gitlab007.xml
@@ -21,6 +21,7 @@
false
true
true
+
master, master2, local-test
diff --git a/tests/triggers/fixtures/gitlab008.xml b/tests/triggers/fixtures/gitlab008.xml
index 4fc9fdaf4..6edb2d32d 100644
--- a/tests/triggers/fixtures/gitlab008.xml
+++ b/tests/triggers/fixtures/gitlab008.xml
@@ -21,6 +21,7 @@
false
true
false
+
diff --git a/tests/triggers/fixtures/gitlab009.plugins_info.yaml b/tests/triggers/fixtures/gitlab009.plugins_info.yaml
new file mode 100644
index 000000000..235eb2914
--- /dev/null
+++ b/tests/triggers/fixtures/gitlab009.plugins_info.yaml
@@ -0,0 +1,3 @@
+- longName: 'GitLab Plugin'
+ shortName: 'gitlab-plugin'
+ version: "0"
diff --git a/tests/triggers/fixtures/gitlab009.xml b/tests/triggers/fixtures/gitlab009.xml
new file mode 100644
index 000000000..3260bdf55
--- /dev/null
+++ b/tests/triggers/fixtures/gitlab009.xml
@@ -0,0 +1,35 @@
+
+
+
+
+ true
+
+
+ true
+ true
+ false
+ false
+ false
+ true
+ Jenkins please retry a build
+ true
+ true
+ true
+ false
+ true
+ true
+ false
+ false
+ false
+
+
+
+
+
+
+ IncludedLabel
+ ExcludedLabel
+
+
+
+
diff --git a/tests/triggers/fixtures/gitlab009.yaml b/tests/triggers/fixtures/gitlab009.yaml
new file mode 100644
index 000000000..55c4fb2a9
--- /dev/null
+++ b/tests/triggers/fixtures/gitlab009.yaml
@@ -0,0 +1,5 @@
+triggers:
+ - gitlab:
+ merge-request-label-filter-config:
+ include: "IncludedLabel"
+ exclude: "ExcludedLabel"