Add a publisher for MQTT
Add support for the MQTT Notification Plugin (https://wiki.jenkins-ci.org/display/JENKINS/MQTT+Notification+Plugin) Change-Id: Ibe867a15f5621601a45c2e1d6281f4db67df29d7
This commit is contained in:
parent
7e3edde3dc
commit
a5eb235881
@ -300,6 +300,52 @@ def campfire(registry, xml_parent, data):
|
|||||||
XML.SubElement(room, 'campfire reference="../../campfire"')
|
XML.SubElement(room, 'campfire reference="../../campfire"')
|
||||||
|
|
||||||
|
|
||||||
|
def mqtt(registry, xml_parent, data):
|
||||||
|
"""yaml: mqtt
|
||||||
|
This plugin lets you send build notifications to a MQTT message queue.
|
||||||
|
Requires the :jenkins-wiki:`MQTT Notification Plugin
|
||||||
|
<MQTT+Notification+Plugin>`.
|
||||||
|
|
||||||
|
:arg str broker-url: the broker URL, as protocol://address:port (required)
|
||||||
|
:arg str credentials-id: credentials to use to connect to the broker
|
||||||
|
(optional)
|
||||||
|
:arg str topic: the message topic (default "jenkins/$PROJECT_URL")
|
||||||
|
:arg str message: the message itself (default "$BUILD_RESULT")
|
||||||
|
:arg str qos: one of AT_MOST_ONCE, AT_LEAST_ONCE, or EXACTLY_ONCE
|
||||||
|
(default AT_MOST_ONCE)
|
||||||
|
:arg bool retain-message: whether to resend message or not when a new
|
||||||
|
client connects (default false)
|
||||||
|
|
||||||
|
Minimal Example:
|
||||||
|
|
||||||
|
.. literalinclude:: /../../tests/publishers/fixtures/mqtt-minimal.yaml
|
||||||
|
:language: yaml
|
||||||
|
|
||||||
|
Full Example:
|
||||||
|
|
||||||
|
.. literalinclude:: /../../tests/publishers/fixtures/mqtt-full.yaml
|
||||||
|
:language: yaml
|
||||||
|
"""
|
||||||
|
|
||||||
|
mqtt = XML.SubElement(xml_parent,
|
||||||
|
'jenkins.plugins.mqttnotification.MqttNotifier')
|
||||||
|
mqtt.set('plugin', 'mqtt-notification-plugin')
|
||||||
|
mqtt_mapping = [
|
||||||
|
('broker-url', 'brokerUrl', None), ]
|
||||||
|
helpers.convert_mapping_to_xml(mqtt, data, mqtt_mapping,
|
||||||
|
fail_required=True)
|
||||||
|
mqtt_mapping = [
|
||||||
|
('credentials-id', 'credentialsId', None),
|
||||||
|
('topic', 'topic', 'jenkins/$PROJECT_URL'),
|
||||||
|
('message', 'message', '$BUILD_RESULT'),
|
||||||
|
('qos', 'qos', 'AT_MOST_ONCE', {'AT_MOST_ONCE': '0',
|
||||||
|
'AT_LEAST_ONCE': '1',
|
||||||
|
'EXACTLY_ONCE': '2'}),
|
||||||
|
('retain-message', 'retainMessage', False)
|
||||||
|
]
|
||||||
|
helpers.convert_mapping_to_xml(mqtt, data, mqtt_mapping)
|
||||||
|
|
||||||
|
|
||||||
def codecover(registry, xml_parent, data):
|
def codecover(registry, xml_parent, data):
|
||||||
"""yaml: codecover
|
"""yaml: codecover
|
||||||
This plugin allows you to capture code coverage report from CodeCover.
|
This plugin allows you to capture code coverage report from CodeCover.
|
||||||
|
13
tests/publishers/fixtures/mqtt-full.xml
Normal file
13
tests/publishers/fixtures/mqtt-full.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<publishers>
|
||||||
|
<jenkins.plugins.mqttnotification.MqttNotifier plugin="mqtt-notification-plugin">
|
||||||
|
<brokerUrl>tcp://localhost:1883</brokerUrl>
|
||||||
|
<credentialsId>abcde</credentialsId>
|
||||||
|
<topic>hello</topic>
|
||||||
|
<message>world</message>
|
||||||
|
<qos>2</qos>
|
||||||
|
<retainMessage>true</retainMessage>
|
||||||
|
</jenkins.plugins.mqttnotification.MqttNotifier>
|
||||||
|
</publishers>
|
||||||
|
</project>
|
8
tests/publishers/fixtures/mqtt-full.yaml
Normal file
8
tests/publishers/fixtures/mqtt-full.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
publishers:
|
||||||
|
- mqtt:
|
||||||
|
broker-url: tcp://localhost:1883
|
||||||
|
topic: hello
|
||||||
|
message: world
|
||||||
|
qos: EXACTLY_ONCE
|
||||||
|
retain-message: true
|
||||||
|
credentials-id: abcde
|
12
tests/publishers/fixtures/mqtt-minimal.xml
Normal file
12
tests/publishers/fixtures/mqtt-minimal.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<project>
|
||||||
|
<publishers>
|
||||||
|
<jenkins.plugins.mqttnotification.MqttNotifier plugin="mqtt-notification-plugin">
|
||||||
|
<brokerUrl>tcp://localhost:1883</brokerUrl>
|
||||||
|
<topic>jenkins/$PROJECT_URL</topic>
|
||||||
|
<message>$BUILD_RESULT</message>
|
||||||
|
<qos>0</qos>
|
||||||
|
<retainMessage>false</retainMessage>
|
||||||
|
</jenkins.plugins.mqttnotification.MqttNotifier>
|
||||||
|
</publishers>
|
||||||
|
</project>
|
3
tests/publishers/fixtures/mqtt-minimal.yaml
Normal file
3
tests/publishers/fixtures/mqtt-minimal.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
publishers:
|
||||||
|
- mqtt:
|
||||||
|
broker-url: tcp://localhost:1883
|
Loading…
Reference in New Issue
Block a user