Add discord-notifier publisher
Plugin page: https://plugins.jenkins.io/discord-notifier/ Requested on: https://github.com/ettoreleandrotognoli/jjb-discord/issues/1 Change-Id: If34f0dec29af661d62f6b7b7110297fd1751ab8e
This commit is contained in:
parent
9ecd7fc92d
commit
d839dc7699
@ -8332,6 +8332,63 @@ def packer(registry, xml_parent, data):
|
||||
)
|
||||
|
||||
|
||||
def discord_notifier(registry, xml_parent, data):
|
||||
"""yaml: discord-notifier
|
||||
This plugin allows for a job to publish results to discord
|
||||
Requires the Jenkins :jenkins-plugins:`discord-notifier`.
|
||||
|
||||
:arg str webhook-url: Discord webhook URL ( required )
|
||||
|
||||
Minimal Example:
|
||||
|
||||
.. literalinclude::
|
||||
/../../tests/publishers/fixtures/discord-notifier-minimal.yaml
|
||||
:language: yaml
|
||||
|
||||
Full Example:
|
||||
|
||||
.. literalinclude::
|
||||
/../../tests/publishers/fixtures/discord-notifier-full.yaml
|
||||
:language: yaml
|
||||
|
||||
"""
|
||||
|
||||
boolean_options = {
|
||||
"send-on-state-change": "sendOnStateChange",
|
||||
"enable-url-linking": "enableUrlLinking",
|
||||
"enable-artifact-list": "enableArtifactList",
|
||||
"enable-footer-info": "enableFooterInfo",
|
||||
"show-changeset": "showChangeset",
|
||||
"send-log-file": "sendLogFile",
|
||||
"send-start-notification": "sendStartNotification",
|
||||
}
|
||||
|
||||
text_options = {
|
||||
"webhook-url": "webhookURL",
|
||||
"branch-name": "branchName",
|
||||
"status-title": "statusTitle",
|
||||
"thumbnail-url": "thumbnailURL",
|
||||
"notes": "notes",
|
||||
"custom-avatar-url": "customAvatarUrl",
|
||||
"custom-username": "customUsername",
|
||||
}
|
||||
|
||||
if data is None:
|
||||
data = dict()
|
||||
|
||||
notifier = XML.SubElement(
|
||||
xml_parent, "nz.co.jammehcow.jenkinsdiscord.WebhookPublisher "
|
||||
)
|
||||
notifier.set("plugin", "discord-notifier@1.4.14")
|
||||
|
||||
for (opt, attr) in text_options.items():
|
||||
(XML.SubElement(notifier, attr).text) = data.get(opt)
|
||||
|
||||
for (opt, attr) in boolean_options.items():
|
||||
value = "true" if data.get(opt, False) else "false"
|
||||
(XML.SubElement(notifier, attr).text) = value
|
||||
|
||||
|
||||
class Publishers(jenkins_jobs.modules.base.Base):
|
||||
sequence = 70
|
||||
|
||||
|
2
tests/publishers/fixtures/discord-notifier-full.conf
Normal file
2
tests/publishers/fixtures/discord-notifier-full.conf
Normal file
@ -0,0 +1,2 @@
|
||||
[plugin "discord-notifier"]
|
||||
param_order_from_yaml = False
|
21
tests/publishers/fixtures/discord-notifier-full.xml
Normal file
21
tests/publishers/fixtures/discord-notifier-full.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<nz.co.jammehcow.jenkinsdiscord.WebhookPublisher plugin="discord-notifier@1.4.14">
|
||||
<webhookURL>https://discord.com/api/webhooks/token</webhookURL>
|
||||
<branchName>branchName</branchName>
|
||||
<statusTitle>statusTitle</statusTitle>
|
||||
<thumbnailURL>thumbnailURL</thumbnailURL>
|
||||
<notes>notes</notes>
|
||||
<customAvatarUrl>customAvatarUrl</customAvatarUrl>
|
||||
<customUsername>customUsername</customUsername>
|
||||
<sendOnStateChange>true</sendOnStateChange>
|
||||
<enableUrlLinking>true</enableUrlLinking>
|
||||
<enableArtifactList>true</enableArtifactList>
|
||||
<enableFooterInfo>true</enableFooterInfo>
|
||||
<showChangeset>true</showChangeset>
|
||||
<sendLogFile>true</sendLogFile>
|
||||
<sendStartNotification>true</sendStartNotification>
|
||||
</nz.co.jammehcow.jenkinsdiscord.WebhookPublisher>
|
||||
</publishers>
|
||||
</project>
|
16
tests/publishers/fixtures/discord-notifier-full.yaml
Normal file
16
tests/publishers/fixtures/discord-notifier-full.yaml
Normal file
@ -0,0 +1,16 @@
|
||||
publishers:
|
||||
- discord-notifier:
|
||||
webhook-url: "https://discord.com/api/webhooks/token"
|
||||
branch-name: "branchName"
|
||||
status-title: "statusTitle"
|
||||
thumbnail-url: "thumbnailURL"
|
||||
notes: "notes"
|
||||
custom-avatar-url: "customAvatarUrl"
|
||||
custom-username: "customUsername"
|
||||
send-on-state-change: true
|
||||
enable-url-linking: true
|
||||
enable-artifact-list: true
|
||||
enable-footer-info: true
|
||||
show-changeset: true
|
||||
send-log-file: true
|
||||
send-start-notification: true
|
2
tests/publishers/fixtures/discord-notifier-minimal.conf
Normal file
2
tests/publishers/fixtures/discord-notifier-minimal.conf
Normal file
@ -0,0 +1,2 @@
|
||||
[plugin "discord-notifier"]
|
||||
param_order_from_yaml = False
|
21
tests/publishers/fixtures/discord-notifier-minimal.xml
Normal file
21
tests/publishers/fixtures/discord-notifier-minimal.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<nz.co.jammehcow.jenkinsdiscord.WebhookPublisher plugin="discord-notifier@1.4.14">
|
||||
<webhookURL>https://discord.com/api/webhooks/token</webhookURL>
|
||||
<branchName/>
|
||||
<statusTitle/>
|
||||
<thumbnailURL/>
|
||||
<notes/>
|
||||
<customAvatarUrl/>
|
||||
<customUsername/>
|
||||
<sendOnStateChange>false</sendOnStateChange>
|
||||
<enableUrlLinking>false</enableUrlLinking>
|
||||
<enableArtifactList>false</enableArtifactList>
|
||||
<enableFooterInfo>false</enableFooterInfo>
|
||||
<showChangeset>false</showChangeset>
|
||||
<sendLogFile>false</sendLogFile>
|
||||
<sendStartNotification>false</sendStartNotification>
|
||||
</nz.co.jammehcow.jenkinsdiscord.WebhookPublisher>
|
||||
</publishers>
|
||||
</project>
|
3
tests/publishers/fixtures/discord-notifier-minimal.yaml
Normal file
3
tests/publishers/fixtures/discord-notifier-minimal.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
publishers:
|
||||
- discord-notifier:
|
||||
webhook-url: "https://discord.com/api/webhooks/token"
|
Loading…
x
Reference in New Issue
Block a user