Update flowdock to use convert_mapping_to_xml()

Change-Id: I70588de4912ea0dbd11ca28c5af2b4f2c78899bd
This commit is contained in:
Yolande Amate 2017-06-25 17:25:04 +01:00 committed by Sorin Sbarnea
parent fcd61f8ad6
commit f97acb632a
4 changed files with 33 additions and 43 deletions

View File

@ -6293,28 +6293,26 @@ def flowdock(registry, xml_parent, data):
.. literalinclude:: /../../tests/publishers/fixtures/flowdock002.yaml
:language: yaml
"""
def gen_notification_entry(data_item, default, text):
e = XML.SubElement(nm, 'entry')
XML.SubElement(e, 'com.flowdock.jenkins.BuildResult').text = text
XML.SubElement(e, 'boolean').text = str(
data.get(data_item, default)).lower()
def gen_setting(item, default):
XML.SubElement(parent, 'notify%s' % item).text = str(
data.get('notify-%s' % item.lower(), default)).lower()
# Raise exception if token was not specified
if 'token' not in data:
raise MissingAttributeError('token')
mapping = [
('', 'com.flowdock.jenkins.BuildResult', text),
(data_item, 'boolean', default)]
helpers.convert_mapping_to_xml(e, data, mapping, fail_required=True)
parent = XML.SubElement(xml_parent,
'com.flowdock.jenkins.FlowdockNotifier')
XML.SubElement(parent, 'flowToken').text = data['token']
XML.SubElement(parent, 'notificationTags').text = data.get('tags', '')
XML.SubElement(parent, 'chatNotification').text = str(
data.get('chat-notification', True)).lower()
mapping = [
('token', 'flowToken', None),
('tags', 'notificationTags', ''),
('chat-notification', 'chatNotification', True),
('notify-success', 'notifySuccess', True),
('notify-failure', 'notifyFailure', True),
('notify-fixed', 'notifyFixed', True),
('notify-unstable', 'notifyUnstable', False),
('notify-aborted', 'notifyAborted', False),
('notify-notbuilt', 'notifyNotBuilt', False)]
helpers.convert_mapping_to_xml(parent, data, mapping, fail_required=True)
nm = XML.SubElement(parent, 'notifyMap')
@ -6326,14 +6324,6 @@ def flowdock(registry, xml_parent, data):
gen_notification_entry('notify-aborted', False, 'ABORTED')
gen_notification_entry('notify-notbuilt', False, 'NOT_BUILT')
# notification settings
gen_setting('Success', True)
gen_setting('Failure', True)
gen_setting('Fixed', True)
gen_setting('Unstable', False)
gen_setting('Aborted', False)
gen_setting('NotBuilt', False)
def clamav(registry, xml_parent, data):
"""yaml: clamav

View File

@ -5,6 +5,12 @@
<flowToken>abcdefghijklmnopqrstuvwxyzabcdef</flowToken>
<notificationTags/>
<chatNotification>true</chatNotification>
<notifySuccess>true</notifySuccess>
<notifyFailure>true</notifyFailure>
<notifyFixed>true</notifyFixed>
<notifyUnstable>false</notifyUnstable>
<notifyAborted>false</notifyAborted>
<notifyNotBuilt>false</notifyNotBuilt>
<notifyMap>
<entry>
<com.flowdock.jenkins.BuildResult>SUCCESS</com.flowdock.jenkins.BuildResult>
@ -31,12 +37,6 @@
<boolean>false</boolean>
</entry>
</notifyMap>
<notifySuccess>true</notifySuccess>
<notifyFailure>true</notifyFailure>
<notifyFixed>true</notifyFixed>
<notifyUnstable>false</notifyUnstable>
<notifyAborted>false</notifyAborted>
<notifyNotBuilt>false</notifyNotBuilt>
</com.flowdock.jenkins.FlowdockNotifier>
</publishers>
</project>

View File

@ -5,6 +5,12 @@
<flowToken>abcdefghijklmnopqrstuvwxyzabcdef</flowToken>
<notificationTags>jenkins,ci</notificationTags>
<chatNotification>true</chatNotification>
<notifySuccess>true</notifySuccess>
<notifyFailure>true</notifyFailure>
<notifyFixed>true</notifyFixed>
<notifyUnstable>false</notifyUnstable>
<notifyAborted>false</notifyAborted>
<notifyNotBuilt>false</notifyNotBuilt>
<notifyMap>
<entry>
<com.flowdock.jenkins.BuildResult>SUCCESS</com.flowdock.jenkins.BuildResult>
@ -31,12 +37,6 @@
<boolean>false</boolean>
</entry>
</notifyMap>
<notifySuccess>true</notifySuccess>
<notifyFailure>true</notifyFailure>
<notifyFixed>true</notifyFixed>
<notifyUnstable>false</notifyUnstable>
<notifyAborted>false</notifyAborted>
<notifyNotBuilt>false</notifyNotBuilt>
</com.flowdock.jenkins.FlowdockNotifier>
</publishers>
</project>

View File

@ -5,6 +5,12 @@
<flowToken>abcdefghijklmnopqrstuvwxyzabcdef</flowToken>
<notificationTags>jenkins,ci</notificationTags>
<chatNotification>false</chatNotification>
<notifySuccess>false</notifySuccess>
<notifyFailure>false</notifyFailure>
<notifyFixed>false</notifyFixed>
<notifyUnstable>true</notifyUnstable>
<notifyAborted>true</notifyAborted>
<notifyNotBuilt>true</notifyNotBuilt>
<notifyMap>
<entry>
<com.flowdock.jenkins.BuildResult>SUCCESS</com.flowdock.jenkins.BuildResult>
@ -31,12 +37,6 @@
<boolean>true</boolean>
</entry>
</notifyMap>
<notifySuccess>false</notifySuccess>
<notifyFailure>false</notifyFailure>
<notifyFixed>false</notifyFixed>
<notifyUnstable>true</notifyUnstable>
<notifyAborted>true</notifyAborted>
<notifyNotBuilt>true</notifyNotBuilt>
</com.flowdock.jenkins.FlowdockNotifier>
</publishers>
</project>