Added gitlab plugin

Change-Id: I43a731cf2d262ca02f69301bcf0d7cf5e82b0ed4
This commit is contained in:
Benjamin Koep 2015-08-11 12:33:12 +02:00
parent 347a231e07
commit 5b21c94af0
8 changed files with 150 additions and 0 deletions

View File

@ -818,6 +818,70 @@ def gitlab_merge_request(parser, xml_parent, data):
XML.SubElement(ghprb, '__projectPath').text = data.get('project-path')
def gitlab(parser, xml_parent, data):
"""yaml: gitlab
Makes Jenkins act like a GitlabCI server
Requires the Jenkins :jenkins-wiki:`Gitlab Plugin.
<Gitlab+Plugin>`.
:arg bool trigger-push: Build on Push Events (default: true)
:arg bool trigger-merge-request: Build on Merge Request Events (default:
True)
:arg bool trigger-open-merge-request-push: Rebuild open Merge Requests on
Push Events (default: True)
:arg bool ci-skip: Enable [ci-skip] (default True)
:arg bool set-build-description: Set build description to build cause
(eg. Merge request or Git Push ) (default: True)
: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
on merge requests (default: True)
:arg bool allow-all-branches: Allow all branches (Ignoring Filtered
Branches) (default: False)
:arg list include-branches: Defined list of branches to include
(default: [])
:arg list exclude-branches: Defined list of branches to exclude
(default: [])
Example:
.. literalinclude::
/../../tests/triggers/fixtures/gitlab001.yaml
"""
def _add_xml(elem, name, value):
XML.SubElement(elem, name).text = value
gitlab = XML.SubElement(
xml_parent, 'com.dabsquared.gitlabjenkins.GitLabPushTrigger'
)
bool_mapping = (
('trigger-push', 'triggerOnPush', True),
('trigger-merge-request', 'triggerOnMergeRequest', True),
('trigger-open-merge-request-push', 'triggerOpenMergeRequestOnPush',
True),
('ci-skip', 'ciSkip', True),
('set-build-description', 'setBuildDescription', True),
('add-note-merge-request', 'addNoteOnMergeRequest', True),
('add-vote-merge-request', 'addVoteOnMergeRequest', True),
('allow-all-branches', 'allowAllBranches', False),
)
list_mapping = (
('include-branches', 'includeBranchesSpec', []),
('exclude-branches', 'excludeBranchesSpec', []),
)
XML.SubElement(gitlab, 'spec').text = ''
for yaml_name, xml_name, default_val in bool_mapping:
value = str(data.get(yaml_name, default_val)).lower()
_add_xml(gitlab, xml_name, value)
for yaml_name, xml_name, default_val in list_mapping:
value = ', '.join(data.get(yaml_name, default_val))
_add_xml(gitlab, xml_name, value)
def build_result(parser, xml_parent, data):
"""yaml: build-result
Configure jobB to monitor jobA build result. A build is scheduled if there

View File

@ -228,6 +228,7 @@ jenkins_jobs.triggers =
gerrit=jenkins_jobs.modules.triggers:gerrit
github=jenkins_jobs.modules.triggers:github
github-pull-request=jenkins_jobs.modules.triggers:github_pull_request
gitlab=jenkins_jobs.modules.triggers:gitlab
gitlab-merge-request=jenkins_jobs.modules.triggers:gitlab_merge_request
groovy-script=jenkins_jobs.modules.triggers:groovy_script
ivy=jenkins_jobs.modules.triggers:ivy

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<triggers class="vector">
<com.dabsquared.gitlabjenkins.GitLabPushTrigger>
<spec/>
<triggerOnPush>true</triggerOnPush>
<triggerOnMergeRequest>true</triggerOnMergeRequest>
<triggerOpenMergeRequestOnPush>true</triggerOpenMergeRequestOnPush>
<ciSkip>true</ciSkip>
<setBuildDescription>true</setBuildDescription>
<addNoteOnMergeRequest>true</addNoteOnMergeRequest>
<addVoteOnMergeRequest>true</addVoteOnMergeRequest>
<allowAllBranches>true</allowAllBranches>
<includeBranchesSpec>master, master2, local-test</includeBranchesSpec>
<excludeBranchesSpec>broken-test, master-foo</excludeBranchesSpec>
</com.dabsquared.gitlabjenkins.GitLabPushTrigger>
</triggers>
</project>

View File

@ -0,0 +1,17 @@
triggers:
- gitlab:
trigger-push: true
trigger-merge-request: true
trigger-open-merge-request-push: true
ci-skip: true
set-build-description: true
add-note-merge-request: true
add-vote-merge-request: true
allow-all-branches: true
include-branches:
- 'master'
- 'master2'
- 'local-test'
exclude-branches:
- 'broken-test'
- 'master-foo'

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<triggers class="vector">
<com.dabsquared.gitlabjenkins.GitLabPushTrigger>
<spec/>
<triggerOnPush>true</triggerOnPush>
<triggerOnMergeRequest>true</triggerOnMergeRequest>
<triggerOpenMergeRequestOnPush>true</triggerOpenMergeRequestOnPush>
<ciSkip>true</ciSkip>
<setBuildDescription>true</setBuildDescription>
<addNoteOnMergeRequest>true</addNoteOnMergeRequest>
<addVoteOnMergeRequest>true</addVoteOnMergeRequest>
<allowAllBranches>false</allowAllBranches>
<includeBranchesSpec>master</includeBranchesSpec>
<excludeBranchesSpec>feature</excludeBranchesSpec>
</com.dabsquared.gitlabjenkins.GitLabPushTrigger>
</triggers>
</project>

View File

@ -0,0 +1,6 @@
triggers:
- gitlab:
include-branches:
- 'master'
exclude-branches:
- 'feature'

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<triggers class="vector">
<com.dabsquared.gitlabjenkins.GitLabPushTrigger>
<spec/>
<triggerOnPush>true</triggerOnPush>
<triggerOnMergeRequest>true</triggerOnMergeRequest>
<triggerOpenMergeRequestOnPush>true</triggerOpenMergeRequestOnPush>
<ciSkip>true</ciSkip>
<setBuildDescription>true</setBuildDescription>
<addNoteOnMergeRequest>true</addNoteOnMergeRequest>
<addVoteOnMergeRequest>true</addVoteOnMergeRequest>
<allowAllBranches>false</allowAllBranches>
<includeBranchesSpec>master</includeBranchesSpec>
<excludeBranchesSpec>baz, foo, fnord</excludeBranchesSpec>
</com.dabsquared.gitlabjenkins.GitLabPushTrigger>
</triggers>
</project>

View File

@ -0,0 +1,8 @@
triggers:
- gitlab:
include-branches:
- 'master'
exclude-branches:
- 'baz'
- 'foo'
- 'fnord'