Add publishers related to GitLab Plugin

Currently we have only possibility to set build status on GitLab
But GitLab Plugin provides us to make a comments and to vote on Merge Request
* Add Gitlab Message - configure Gitlab publisher to post comments on MR
* Add Gitlab Vote - jenkins set Vote for build status on GitLab MR

Change-Id: I30d2fbed647763f2a5eb6fb801dd79f6d43d4696
Co-Authored-By: Kien Ha <kienha9922@gmail.com>
Signed-off-by: Kien Ha <kienha9922@gmail.com>
This commit is contained in:
vgorin 2017-11-09 00:06:18 +03:00 committed by Kien Ha
parent a0564c85de
commit 29a8ad7683
7 changed files with 120 additions and 0 deletions

View File

@ -4761,6 +4761,73 @@ def gitlab_notifier(registry, xml_parent, data):
helpers.convert_mapping_to_xml(top, data, mappings, fail_required=True)
def gitlab_vote(registry, xml_parent, data):
"""yaml: gitlab-vote
Set vote for build status on GitLab merge request.
Requires the Jenkins :jenkins-wiki:`GitLab Plugin <GitLab+Plugin>`.
Example:
.. literalinclude::
../../tests/publishers/fixtures/gitlab-vote.yaml
:language: yaml
"""
XML.SubElement(
xml_parent,
'com.dabsquared.gitlabjenkins.publisher.GitLabVotePublisher')
def gitlab_message(registry, xml_parent, data):
"""yaml: gitlab-message
Add note with build status on GitLab merge request.
Requires the Jenkins :jenkins-wiki:`GitLab Plugin <GitLab+Plugin>`.
:arg bool failure-only: make a comment only on failure (default false)
:arg bool success-note: make a comment on GitLab Merge Request
if build succeeds (default false)
:arg bool failure-note: make a comment on GitLab Merge Request
if build failed (default false)
:arg bool abort-note: make a comment on GitLab Merge Request
if build aborted (default false)
:arg bool unstable-note: make a comment on GitLab Merge Request
if build unstable (default false)
:arg str success-note-text: text of comment on success build (default '')
:arg str failure-note-text: text of comment on failed build (default '')
:arg str abort-note-text: text of comment on aborted build (default '')
:arg str unstable-note-text: text of comment on unstable build (default '')
Minimal Example:
.. literalinclude::
/../../tests/publishers/fixtures/gitlab-message-minimal.yaml
:language: yaml
Full Example:
.. literalinclude::
/../../tests/publishers/fixtures/gitlab-message-full.yaml
:language: yaml
"""
gitlab = XML.SubElement(
xml_parent,
'com.dabsquared.gitlabjenkins.publisher.GitLabMessagePublisher'
)
gitlab.set('plugin', 'gitlab-plugin')
mapping = [('failure-only', 'onlyForFailure', False),
('success-note', 'replaceSuccessNote', False),
('failure-note', 'replaceFailureNote', False),
('abort-note', 'replaceAbortNote', False),
('unstable-note', 'replaceUnstableNote', False),
('success-note-text', 'successNoteText', ''),
('failure-note-text', 'failureNoteText', ''),
('abort-note-text', 'abortNoteText', ''),
('unstable-note-text', 'unstableNoteText', '')]
helpers.convert_mapping_to_xml(gitlab, data, mapping, fail_required=True)
def zulip(registry, xml_parent, data):
"""yaml: zulip
Set build status on zulip.

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<com.dabsquared.gitlabjenkins.publisher.GitLabMessagePublisher plugin="gitlab-plugin">
<onlyForFailure>true</onlyForFailure>
<replaceSuccessNote>true</replaceSuccessNote>
<replaceFailureNote>true</replaceFailureNote>
<replaceAbortNote>true</replaceAbortNote>
<replaceUnstableNote>true</replaceUnstableNote>
<successNoteText>SUCCESS</successNoteText>
<failureNoteText>Build was failed. See log on Jenkins</failureNoteText>
<abortNoteText>Build was aborted</abortNoteText>
<unstableNoteText>The build is unstable</unstableNoteText>
</com.dabsquared.gitlabjenkins.publisher.GitLabMessagePublisher>
</publishers>
</project>

View File

@ -0,0 +1,11 @@
publishers:
- gitlab-message:
failure-only: true
success-note: true
success-note-text: "SUCCESS"
failure-note: true
failure-note-text: "Build was failed. See log on Jenkins"
abort-note: true
abort-note-text: "Build was aborted"
unstable-note: true
unstable-note-text: "The build is unstable"

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<com.dabsquared.gitlabjenkins.publisher.GitLabMessagePublisher plugin="gitlab-plugin">
<onlyForFailure>false</onlyForFailure>
<replaceSuccessNote>false</replaceSuccessNote>
<replaceFailureNote>false</replaceFailureNote>
<replaceAbortNote>false</replaceAbortNote>
<replaceUnstableNote>false</replaceUnstableNote>
<successNoteText/>
<failureNoteText/>
<abortNoteText/>
<unstableNoteText/>
</com.dabsquared.gitlabjenkins.publisher.GitLabMessagePublisher>
</publishers>
</project>

View File

@ -0,0 +1,2 @@
publishers:
- gitlab-message

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<com.dabsquared.gitlabjenkins.publisher.GitLabVotePublisher/>
</publishers>
</project>

View File

@ -0,0 +1,2 @@
publishers:
- gitlab-vote