Add support for 'RocketChat Notifier Plugin'
Change-Id: I78755fb1d116a6e164817589457fe132b81a89eb Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@gmail.com>
This commit is contained in:
parent
9f84f69f3c
commit
b67c0bc754
jenkins_jobs/modules
tests/publishers/fixtures
@ -1267,6 +1267,133 @@ def ftp_publisher(registry, xml_parent, data):
|
||||
helpers.convert_mapping_to_xml(ftp, data, mapping, fail_required=True)
|
||||
|
||||
|
||||
def rocket(registry, xml_parent, data):
|
||||
"""yaml: rocket
|
||||
RocketChat notification on build completion,
|
||||
Requires the `RocketChat Notifier Plugin`.
|
||||
|
||||
:arg str channel: Comma separated list of rooms (e.g. #project)
|
||||
or persons (e.g. @john)
|
||||
:arg bool abort: Notify abort (default false)
|
||||
:arg bool start: Notify start (default false)
|
||||
:arg bool success: Notify success (default false)
|
||||
:arg bool failure: Notify failure (default false)
|
||||
:arg bool repeated-failure: Notify repeated failure (default false)
|
||||
:arg bool back-to-normal: Notify back to normal (default false)
|
||||
:arg bool not-built: Notify if not built (default false)
|
||||
:arg bool unstable: Notify if unstable (default false)
|
||||
:arg str webhook-token: Webhook token for posting messages.
|
||||
Overrides global authentication data and channel
|
||||
:arg str commit-info: What commit information to include into
|
||||
notification message.
|
||||
|
||||
:commit-info values:
|
||||
* **none**
|
||||
* **authors**
|
||||
* **authors-and-titles**
|
||||
|
||||
:arg str custom-message: Custom text message (default '')
|
||||
:arg bool trust-ssl: Trust RocketChat server certificate, if checked,
|
||||
the SSL certificate will not be checked (default false)
|
||||
:arg str build-server: Build Server URL
|
||||
:arg list attachments: Optional list of attachments
|
||||
|
||||
:attachments:
|
||||
* **title** (`str`) Attachment title (required)
|
||||
* **title-link** (`str`)
|
||||
* **title-link-download** (`bool`)
|
||||
* **color** (`str`)
|
||||
* **text** (`str`)
|
||||
* **collapsed** (`bool`)
|
||||
* **message-link** (`str`)
|
||||
* **author-name** (`str`)
|
||||
* **author-link** (`str`)
|
||||
* **author-icon** (`str`)
|
||||
* **thumb** (`str`) Thumb URL
|
||||
* **image** (`str`) Image URL
|
||||
* **audio** (`str`) Audio URL
|
||||
* **video** (`str`) Video URL
|
||||
|
||||
Minimal example using defaults:
|
||||
|
||||
.. literalinclude:: /../../tests/publishers/fixtures/rocket001.yaml
|
||||
:language: yaml
|
||||
|
||||
Full example:
|
||||
|
||||
.. literalinclude:: /../../tests/publishers/fixtures/rocket002.yaml
|
||||
:language: yaml
|
||||
"""
|
||||
rocketchat = XML.SubElement(xml_parent,
|
||||
'jenkins.plugins.rocketchatnotifier.RocketChatNotifier')
|
||||
rocketchat.set('plugin', 'rocketchatnotifier')
|
||||
required_mapping = [
|
||||
('channel', 'channel', ''),
|
||||
('start', 'startNotification', False),
|
||||
('success', 'notifySuccess', False),
|
||||
('abort', 'notifyAborted', False),
|
||||
('not-built', 'notifyNotBuilt', False),
|
||||
('unstable', 'notifyUnstable', False),
|
||||
('failure', 'notifyFailure', False),
|
||||
('back-to-normal', 'notifyBackToNormal', False),
|
||||
('repeated-failure', 'notifyRepeatedFailure', False),
|
||||
('include-test-summary', 'includeTestSummary', False),
|
||||
('include-test-log', 'includeTestLog', False),
|
||||
('include-custom-message', 'includeCustomMessage', False),
|
||||
('commit-info', 'commitInfoChoice', 'none',
|
||||
{
|
||||
'none': 'NONE',
|
||||
'authors': 'AUTHORS',
|
||||
'authors-and-titles': 'AUTHORS_AND_TITLES'
|
||||
}),
|
||||
('raw-message', 'rawMessage', False),
|
||||
('webhook-token', 'webhookToken', ''),
|
||||
('webhook-token-credential-id', 'webhookTokenCredentialId', ''),
|
||||
]
|
||||
optional_mapping = [
|
||||
('trust-ssl', 'trustSSL', None),
|
||||
('build-server', 'buildServerUrl', None),
|
||||
]
|
||||
|
||||
helpers.convert_mapping_to_xml(
|
||||
rocketchat, data, optional_mapping, fail_required=False)
|
||||
helpers.convert_mapping_to_xml(
|
||||
rocketchat, data, required_mapping, fail_required=True)
|
||||
|
||||
attach_required_mapping = [
|
||||
('title', 'title', None),
|
||||
]
|
||||
attach_optional_mapping = [
|
||||
('title-link', 'titleLink', None),
|
||||
('title-link-download', 'titleLinkDownload', None),
|
||||
('color', 'color', None),
|
||||
('text', 'text', None),
|
||||
('collapsed', 'collapsed', None), # false | true
|
||||
('message-link', 'messageLink', None),
|
||||
('author-name', 'authorName', None),
|
||||
('author-link', 'authorLink', None),
|
||||
('author-icon', 'authorIcon', None),
|
||||
('thumb', 'thumbUrl', None),
|
||||
('image', 'imageUrl', None),
|
||||
('audio', 'audioUrl', None),
|
||||
('video', 'videoUrl', None),
|
||||
]
|
||||
attach_list = data.get('attachments', None)
|
||||
|
||||
attachments = XML.SubElement(rocketchat, 'attachments')
|
||||
if attach_list is not None:
|
||||
for attach_data in attach_list:
|
||||
item = XML.SubElement(attachments,
|
||||
'jenkins.plugins.rocketchatnotifier.model.MessageAttachment')
|
||||
helpers.convert_mapping_to_xml(item, attach_data,
|
||||
attach_required_mapping, fail_required=True)
|
||||
helpers.convert_mapping_to_xml(item, attach_data,
|
||||
attach_optional_mapping, fail_required=False)
|
||||
|
||||
XML.SubElement(rocketchat, 'customMessage').text = \
|
||||
data.get('custom-message', '')
|
||||
|
||||
|
||||
def junit(registry, xml_parent, data):
|
||||
"""yaml: junit
|
||||
Publish JUnit test results.
|
||||
|
25
tests/publishers/fixtures/rocket001.xml
Normal file
25
tests/publishers/fixtures/rocket001.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<jenkins.plugins.rocketchatnotifier.RocketChatNotifier plugin="rocketchatnotifier">
|
||||
<channel/>
|
||||
<startNotification>false</startNotification>
|
||||
<notifySuccess>false</notifySuccess>
|
||||
<notifyAborted>false</notifyAborted>
|
||||
<notifyNotBuilt>false</notifyNotBuilt>
|
||||
<notifyUnstable>false</notifyUnstable>
|
||||
<notifyFailure>false</notifyFailure>
|
||||
<notifyBackToNormal>false</notifyBackToNormal>
|
||||
<notifyRepeatedFailure>false</notifyRepeatedFailure>
|
||||
<includeTestSummary>false</includeTestSummary>
|
||||
<includeTestLog>false</includeTestLog>
|
||||
<includeCustomMessage>false</includeCustomMessage>
|
||||
<commitInfoChoice>NONE</commitInfoChoice>
|
||||
<rawMessage>false</rawMessage>
|
||||
<webhookToken/>
|
||||
<webhookTokenCredentialId/>
|
||||
<attachments/>
|
||||
<customMessage/>
|
||||
</jenkins.plugins.rocketchatnotifier.RocketChatNotifier>
|
||||
</publishers>
|
||||
</project>
|
3
tests/publishers/fixtures/rocket001.yaml
Normal file
3
tests/publishers/fixtures/rocket001.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
publishers:
|
||||
- rocket:
|
||||
channel: ''
|
56
tests/publishers/fixtures/rocket002.xml
Normal file
56
tests/publishers/fixtures/rocket002.xml
Normal file
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<jenkins.plugins.rocketchatnotifier.RocketChatNotifier plugin="rocketchatnotifier">
|
||||
<trustSSL>true</trustSSL>
|
||||
<buildServerUrl>http://localhost:8080/</buildServerUrl>
|
||||
<channel>#channel,@user</channel>
|
||||
<startNotification>true</startNotification>
|
||||
<notifySuccess>true</notifySuccess>
|
||||
<notifyAborted>true</notifyAborted>
|
||||
<notifyNotBuilt>true</notifyNotBuilt>
|
||||
<notifyUnstable>true</notifyUnstable>
|
||||
<notifyFailure>true</notifyFailure>
|
||||
<notifyBackToNormal>true</notifyBackToNormal>
|
||||
<notifyRepeatedFailure>true</notifyRepeatedFailure>
|
||||
<includeTestSummary>true</includeTestSummary>
|
||||
<includeTestLog>true</includeTestLog>
|
||||
<includeCustomMessage>true</includeCustomMessage>
|
||||
<commitInfoChoice>AUTHORS_AND_TITLES</commitInfoChoice>
|
||||
<rawMessage>true</rawMessage>
|
||||
<webhookToken>non-secure-webhook-token</webhookToken>
|
||||
<webhookTokenCredentialId>secret-text-id</webhookTokenCredentialId>
|
||||
<attachments>
|
||||
<jenkins.plugins.rocketchatnotifier.model.MessageAttachment>
|
||||
<title>The Black</title>
|
||||
</jenkins.plugins.rocketchatnotifier.model.MessageAttachment>
|
||||
<jenkins.plugins.rocketchatnotifier.model.MessageAttachment>
|
||||
<title>The Red</title>
|
||||
<color>red</color>
|
||||
</jenkins.plugins.rocketchatnotifier.model.MessageAttachment>
|
||||
<jenkins.plugins.rocketchatnotifier.model.MessageAttachment>
|
||||
<title>The Blue</title>
|
||||
<color>blue</color>
|
||||
<text>The navy blue</text>
|
||||
</jenkins.plugins.rocketchatnotifier.model.MessageAttachment>
|
||||
<jenkins.plugins.rocketchatnotifier.model.MessageAttachment>
|
||||
<title>The White</title>
|
||||
<titleLink>title_link</titleLink>
|
||||
<titleLinkDownload>true</titleLinkDownload>
|
||||
<color>white</color>
|
||||
<text>All&all</text>
|
||||
<collapsed>true</collapsed>
|
||||
<messageLink>message_link</messageLink>
|
||||
<authorName>author_name</authorName>
|
||||
<authorLink>author_link</authorLink>
|
||||
<authorIcon>author_icon</authorIcon>
|
||||
<thumbUrl>http://hostname/thumb.png</thumbUrl>
|
||||
<imageUrl>http://hostname/image.jpg</imageUrl>
|
||||
<audioUrl>http://hostname/audio.mp3</audioUrl>
|
||||
<videoUrl>http://hostname/video.avi</videoUrl>
|
||||
</jenkins.plugins.rocketchatnotifier.model.MessageAttachment>
|
||||
</attachments>
|
||||
<customMessage>Hello World!</customMessage>
|
||||
</jenkins.plugins.rocketchatnotifier.RocketChatNotifier>
|
||||
</publishers>
|
||||
</project>
|
42
tests/publishers/fixtures/rocket002.yaml
Normal file
42
tests/publishers/fixtures/rocket002.yaml
Normal file
@ -0,0 +1,42 @@
|
||||
publishers:
|
||||
- rocket:
|
||||
channel: '#channel,@user'
|
||||
abort: true
|
||||
back-to-normal: true
|
||||
failure: true
|
||||
not-built: true
|
||||
repeated-failure: true
|
||||
start: true
|
||||
success: true
|
||||
unstable: true
|
||||
trust-ssl: true
|
||||
build-server: 'http://localhost:8080/'
|
||||
webhook-token: 'non-secure-webhook-token'
|
||||
webhook-token-credential-id: 'secret-text-id'
|
||||
commit-info: 'authors-and-titles'
|
||||
include-custom-message: true
|
||||
include-test-log: true
|
||||
include-test-summary: true
|
||||
custom-message: 'Hello World!'
|
||||
raw-message: true
|
||||
attachments:
|
||||
- title: The Black
|
||||
- title: The Red
|
||||
color: red
|
||||
- title: The Blue
|
||||
color: blue
|
||||
text: The navy blue
|
||||
- title: The White
|
||||
title-link: title_link
|
||||
title-link-download: true
|
||||
message-link: message_link
|
||||
color: white
|
||||
text: 'All&all'
|
||||
collapsed: true
|
||||
author-name: author_name
|
||||
author-link: author_link
|
||||
author-icon: author_icon
|
||||
thumb: 'http://hostname/thumb.png'
|
||||
image: 'http://hostname/image.jpg'
|
||||
audio: 'http://hostname/audio.mp3'
|
||||
video: 'http://hostname/video.avi'
|
Loading…
Reference in New Issue
Block a user