Support all parameters in gitlab-merge-request

Change-Id: I21c667515b7073a19696a8d8f27d9cf2b4278504
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
This commit is contained in:
Lukas Lowinger 2017-03-29 13:00:01 +02:00 committed by Thanh Ha
parent a23f8bf8db
commit ed1c647aaf
No known key found for this signature in database
GPG Key ID: B0CB27E00DA095AA
3 changed files with 44 additions and 11 deletions

View File

@ -1169,8 +1169,22 @@ def gitlab_merge_request(registry, xml_parent, data):
Requires the Jenkins :jenkins-wiki:`Gitlab MergeRequest Builder Plugin.
<Gitlab+Merge+Request+Builder+Plugin>`.
:arg string cron: cron syntax of when to run (required)
:arg string project-path: gitlab-relative path to project (required)
:arg string cron: Cron syntax of when to run (required)
:arg string project-path: Gitlab-relative path to project (required)
:arg string use-http-url: Use the HTTP(S) URL to fetch/clone repository
(default false)
:arg string assignee-filter: Only MRs with this assigned user will
trigger the build automatically (default 'jenkins')
:arg string tag-filter: Only MRs with this label will trigger the build
automatically (default 'Build')
:arg string trigger-comment: Force build if this comment is the last
in merge reguest (default '')
:arg string publish-build-progress-messages: Publish build progress
messages (except build failed) (default true)
:arg string auto-close-failed: On failure, auto close the request
(default false)
:arg string auto-merge-passed: On success, auto merge the request
(default false)
Example:
@ -1179,20 +1193,25 @@ def gitlab_merge_request(registry, xml_parent, data):
"""
ghprb = XML.SubElement(xml_parent, 'org.jenkinsci.plugins.gitlab.'
'GitlabBuildTrigger')
if not data.get('cron', None):
raise jenkins_jobs.errors.JenkinsJobsException(
'gitlab-merge-request is missing "cron"')
if not data.get('project-path', None):
raise jenkins_jobs.errors.JenkinsJobsException(
'gitlab-merge-request is missing "project-path"')
# Because of a design limitation in the GitlabBuildTrigger Jenkins plugin
# both 'spec' and '__cron' have to be set to the same value to have them
# take effect. Also, cron and projectPath are prefixed with underscores
# in the plugin, but spec is not.
XML.SubElement(ghprb, 'spec').text = data.get('cron')
XML.SubElement(ghprb, '__cron').text = data.get('cron')
XML.SubElement(ghprb, '__projectPath').text = data.get('project-path')
mapping = [
('cron', 'spec', None),
('cron', '__cron', None),
('project-path', '__projectPath', None),
('use-http-url', '__useHttpUrl', False),
('assignee-filter', '__assigneeFilter', 'jenkins'),
('tag-filter', '__tagFilter', 'Build'),
('trigger-comment', '__triggerComment', ''),
('publish-build-progress-messages', '__publishBuildProgressMessages',
True),
('auto-close-failed', '__autoCloseFailed', False),
('auto-merge-passed', '__autoMergePassed', False)
]
convert_mapping_to_xml(ghprb, data, mapping, True)
def gitlab(registry, xml_parent, data):

View File

@ -5,6 +5,13 @@
<spec>* * * * *</spec>
<__cron>* * * * *</__cron>
<__projectPath>test/project</__projectPath>
<__useHttpUrl>false</__useHttpUrl>
<__assigneeFilter>jenkinsbot</__assigneeFilter>
<__tagFilter>fix</__tagFilter>
<__triggerComment>rebuild</__triggerComment>
<__publishBuildProgressMessages>true</__publishBuildProgressMessages>
<__autoCloseFailed>false</__autoCloseFailed>
<__autoMergePassed>false</__autoMergePassed>
</org.jenkinsci.plugins.gitlab.GitlabBuildTrigger>
</triggers>
</project>

View File

@ -2,3 +2,10 @@ triggers:
- gitlab-merge-request:
cron: '* * * * *'
project-path: 'test/project'
use-http-url: false
assignee-filter: 'jenkinsbot'
tag-filter: 'fix'
trigger-comment: 'rebuild'
publish-build-progress-messages: true
auto-close-failed: false
auto-merge-passed: false