Add Gitlab Merge Request trigger
Change-Id: Ic068cf7e89be76f0f9e9187caf628fa49d7bd7fd
This commit is contained in:
parent
d833015640
commit
41af1b9e98
@ -407,6 +407,39 @@ def github_pull_request(parser, xml_parent, data):
|
|||||||
data.get('auto-close-on-fail', False)).lower()
|
data.get('auto-close-on-fail', False)).lower()
|
||||||
|
|
||||||
|
|
||||||
|
def gitlab_merge_request(parser, xml_parent, data):
|
||||||
|
"""yaml: gitlab-merge-request
|
||||||
|
Build merge requests in gitlab and report results.
|
||||||
|
Requires the Jenkins `Gitlab MergeRequest Builder Plugin.
|
||||||
|
<https://wiki.jenkins-ci.org/display/JENKINS/
|
||||||
|
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)
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
.. literalinclude:: \
|
||||||
|
/../../tests/triggers/fixtures/gitlab-merge-request.yaml
|
||||||
|
"""
|
||||||
|
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')
|
||||||
|
|
||||||
|
|
||||||
def build_result(parser, xml_parent, data):
|
def build_result(parser, xml_parent, data):
|
||||||
"""yaml: build-result
|
"""yaml: build-result
|
||||||
Configure jobB to monitor jobA build result. A build is scheduled if there
|
Configure jobB to monitor jobA build result. A build is scheduled if there
|
||||||
|
@ -171,6 +171,7 @@ jenkins_jobs.triggers =
|
|||||||
gerrit=jenkins_jobs.modules.triggers:gerrit
|
gerrit=jenkins_jobs.modules.triggers:gerrit
|
||||||
github=jenkins_jobs.modules.triggers:github
|
github=jenkins_jobs.modules.triggers:github
|
||||||
github-pull-request=jenkins_jobs.modules.triggers:github_pull_request
|
github-pull-request=jenkins_jobs.modules.triggers:github_pull_request
|
||||||
|
gitlab-merge-request=jenkins_jobs.modules.triggers:gitlab_merge_request
|
||||||
pollscm=jenkins_jobs.modules.triggers:pollscm
|
pollscm=jenkins_jobs.modules.triggers:pollscm
|
||||||
script=jenkins_jobs.modules.triggers:script
|
script=jenkins_jobs.modules.triggers:script
|
||||||
timed=jenkins_jobs.modules.triggers:timed
|
timed=jenkins_jobs.modules.triggers:timed
|
||||||
|
10
tests/triggers/fixtures/gitlab-merge-request.xml
Normal file
10
tests/triggers/fixtures/gitlab-merge-request.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<triggers class="vector">
|
||||||
|
<org.jenkinsci.plugins.gitlab.GitlabBuildTrigger>
|
||||||
|
<spec>* * * * *</spec>
|
||||||
|
<__cron>* * * * *</__cron>
|
||||||
|
<__projectPath>test/project</__projectPath>
|
||||||
|
</org.jenkinsci.plugins.gitlab.GitlabBuildTrigger>
|
||||||
|
</triggers>
|
||||||
|
</project>
|
4
tests/triggers/fixtures/gitlab-merge-request.yaml
Normal file
4
tests/triggers/fixtures/gitlab-merge-request.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
triggers:
|
||||||
|
- gitlab-merge-request:
|
||||||
|
cron: '* * * * *'
|
||||||
|
project-path: 'test/project'
|
Loading…
Reference in New Issue
Block a user