triggers/gitlab: allow setting the merge request pending build name

Add a "pending-build-name" parameter to control the pendingBuildName XML
attribute which controls the pending build name in the Gitlab merge request.

Change-Id: Iee229a047cbeef6fe842c010feb7963412667066
This commit is contained in:
David Aguilar 2021-02-03 17:05:44 -08:00
parent 4f615ee5ec
commit 4393f8ba1a
3 changed files with 7 additions and 2 deletions

View File

@ -1573,6 +1573,7 @@ def gitlab(registry, xml_parent, data):
(eg. Merge request or Git Push) (default true)
:arg bool cancel-pending-builds-on-update: Cancel pending merge request
builds on update (default false)
:arg str pending-build-name: Set the pending merge request build name (optional)
:arg bool add-note-merge-request: Add note with build status on
merge requests (default true)
:arg bool add-vote-merge-request: Vote added to note with build status
@ -1693,17 +1694,19 @@ def gitlab(registry, xml_parent, data):
("target-branch-regex", "targetBranchRegex", ""),
("secret-token", "secretToken", ""),
]
helpers.convert_mapping_to_xml(gitlab, data, mapping, fail_required=True)
list_mapping = (
("include-branches", "includeBranchesSpec", []),
("exclude-branches", "excludeBranchesSpec", []),
)
helpers.convert_mapping_to_xml(gitlab, data, mapping, fail_required=True)
for yaml_name, xml_name, default_val in list_mapping:
value = ", ".join(data.get(yaml_name, default_val))
_add_xml(gitlab, xml_name, value)
optional_mapping = (("pending-build-name", "pendingBuildName", None),)
helpers.convert_mapping_to_xml(gitlab, data, optional_mapping, fail_required=False)
def gogs(registry, xml_parent, data):
"""yaml: gogs

View File

@ -24,6 +24,7 @@
<secretToken/>
<includeBranchesSpec>master, master2, local-test</includeBranchesSpec>
<excludeBranchesSpec>broken-test, master-foo</excludeBranchesSpec>
<pendingBuildName>test</pendingBuildName>
</com.dabsquared.gitlabjenkins.GitLabPushTrigger>
</triggers>
</project>

View File

@ -16,3 +16,4 @@ triggers:
exclude-branches:
- 'broken-test'
- 'master-foo'
pending-build-name: 'test'