Update jabber plugin
- update jabber plugin to use convert xml - add plugin="jabber" and plugin="instant-messaging" attribute - update test cases - add new notification strategy option Change-Id: I221f75f30e611ca206041be6f9a86e4075f6bb8d
This commit is contained in:
parent
e47f9629bc
commit
0bdd819969
@ -2767,6 +2767,7 @@ def jabber(registry, xml_parent, data):
|
||||
* **all** -- Always
|
||||
* **failure** -- On any failure
|
||||
* **failure-fixed** -- On failure and fixes
|
||||
* **new-failure-fixed** -- On new failure and fixes
|
||||
* **change** -- Only on state change
|
||||
:arg dict message: Channel notification message (default summary-scm)
|
||||
|
||||
@ -2776,45 +2777,55 @@ def jabber(registry, xml_parent, data):
|
||||
* **summary-build** -- Summary and build parameters
|
||||
* **summary-scm-fail** -- Summary, SCM changes, and failed tests
|
||||
|
||||
Example:
|
||||
Minimal Example:
|
||||
|
||||
.. literalinclude:: /../../tests/publishers/fixtures/jabber001.yaml
|
||||
.. literalinclude:: /../../tests/publishers/fixtures/jabber-minimal.yaml
|
||||
:language: yaml
|
||||
|
||||
Full Example:
|
||||
|
||||
.. literalinclude:: /../../tests/publishers/fixtures/jabber-complete.yaml
|
||||
:language: yaml
|
||||
"""
|
||||
j = XML.SubElement(xml_parent, 'hudson.plugins.jabber.im.transport.'
|
||||
'JabberPublisher')
|
||||
j.set('plugin', 'jabber')
|
||||
|
||||
t = XML.SubElement(j, 'targets')
|
||||
if 'group-targets' in data:
|
||||
for group in data['group-targets']:
|
||||
gcimt = XML.SubElement(t, 'hudson.plugins.im.'
|
||||
'GroupChatIMMessageTarget')
|
||||
gcimt.set('plugin', 'instant-messaging')
|
||||
XML.SubElement(gcimt, 'name').text = group
|
||||
XML.SubElement(gcimt, 'notificationOnly').text = 'false'
|
||||
if 'individual-targets' in data:
|
||||
for individual in data['individual-targets']:
|
||||
dimt = XML.SubElement(t, 'hudson.plugins.im.'
|
||||
'DefaultIMMessageTarget')
|
||||
dimt.set('plugin', 'instant-messaging')
|
||||
XML.SubElement(dimt, 'value').text = individual
|
||||
strategy = data.get('strategy', 'all')
|
||||
strategydict = {'all': 'ALL',
|
||||
'failure': 'ANY_FAILURE',
|
||||
'failure-fixed': 'FAILURE_AND_FIXED',
|
||||
'new-failure-fixed': 'NEW_FAILURE_AND_FIXED',
|
||||
'change': 'STATECHANGE_ONLY'}
|
||||
if strategy not in strategydict:
|
||||
raise JenkinsJobsException("Strategy entered is not valid, must be " +
|
||||
"one of: all, failure, failure-fixed, or "
|
||||
"change")
|
||||
XML.SubElement(j, 'strategy').text = strategydict[strategy]
|
||||
XML.SubElement(j, 'notifyOnBuildStart').text = str(
|
||||
data.get('notify-on-build-start', False)).lower()
|
||||
XML.SubElement(j, 'notifySuspects').text = str(
|
||||
data.get('notify-scm-committers', False)).lower()
|
||||
XML.SubElement(j, 'notifyCulprits').text = str(
|
||||
data.get('notify-scm-culprits', False)).lower()
|
||||
XML.SubElement(j, 'notifyFixers').text = str(
|
||||
data.get('notify-scm-fixers', False)).lower()
|
||||
XML.SubElement(j, 'notifyUpstreamCommitters').text = str(
|
||||
data.get('notify-upstream-committers', False)).lower()
|
||||
|
||||
mappings = [
|
||||
('notify-on-build-start', 'notifyOnBuildStart', False),
|
||||
('notify-scm-committers', 'notifySuspects', False),
|
||||
('notify-scm-culprits', 'notifyCulprits', False),
|
||||
('notify-scm-fixers', 'notifyFixers', False),
|
||||
('notify-upstream-committers', 'notifyUpstreamCommitters', False)
|
||||
]
|
||||
helpers.convert_mapping_to_xml(j, data, mappings, fail_required=True)
|
||||
|
||||
message = data.get('message', 'summary-scm')
|
||||
messagedict = {'summary-scm': 'DefaultBuildToChatNotifier',
|
||||
'summary': 'SummaryOnlyBuildToChatNotifier',
|
||||
|
@ -1,23 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.jabber.im.transport.JabberPublisher>
|
||||
<hudson.plugins.jabber.im.transport.JabberPublisher plugin="jabber">
|
||||
<targets>
|
||||
<hudson.plugins.im.GroupChatIMMessageTarget>
|
||||
<hudson.plugins.im.GroupChatIMMessageTarget plugin="instant-messaging">
|
||||
<name>foo-room@conference-2-fooserver.foo.com</name>
|
||||
<notificationOnly>false</notificationOnly>
|
||||
</hudson.plugins.im.GroupChatIMMessageTarget>
|
||||
<hudson.plugins.im.DefaultIMMessageTarget>
|
||||
<hudson.plugins.im.DefaultIMMessageTarget plugin="instant-messaging">
|
||||
<value>foo-user@conference-2-fooserver.foo.com</value>
|
||||
</hudson.plugins.im.DefaultIMMessageTarget>
|
||||
</targets>
|
||||
<strategy>ALL</strategy>
|
||||
<strategy>NEW_FAILURE_AND_FIXED</strategy>
|
||||
<notifyOnBuildStart>true</notifyOnBuildStart>
|
||||
<notifySuspects>false</notifySuspects>
|
||||
<notifyCulprits>false</notifyCulprits>
|
||||
<notifyFixers>false</notifyFixers>
|
||||
<notifyUpstreamCommitters>false</notifyUpstreamCommitters>
|
||||
<buildToChatNotifier class="hudson.plugins.im.build_notify.DefaultBuildToChatNotifier"/>
|
||||
<notifySuspects>true</notifySuspects>
|
||||
<notifyCulprits>true</notifyCulprits>
|
||||
<notifyFixers>true</notifyFixers>
|
||||
<notifyUpstreamCommitters>true</notifyUpstreamCommitters>
|
||||
<buildToChatNotifier class="hudson.plugins.im.build_notify.SummaryOnlyBuildToChatNotifier"/>
|
||||
<matrixMultiplier>ONLY_CONFIGURATIONS</matrixMultiplier>
|
||||
</hudson.plugins.jabber.im.transport.JabberPublisher>
|
||||
</publishers>
|
@ -1,9 +1,13 @@
|
||||
publishers:
|
||||
- jabber:
|
||||
notify-on-build-start: true
|
||||
notify-scm-committers: true
|
||||
notify-scm-culprits: true
|
||||
notify-upstream-committers: true
|
||||
notify-scm-fixers: true
|
||||
group-targets:
|
||||
- "foo-room@conference-2-fooserver.foo.com"
|
||||
individual-targets:
|
||||
- "foo-user@conference-2-fooserver.foo.com"
|
||||
strategy: all
|
||||
message: summary-scm
|
||||
strategy: new-failure-fixed
|
||||
message: summary
|
16
tests/publishers/fixtures/jabber-minimal.xml
Normal file
16
tests/publishers/fixtures/jabber-minimal.xml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<publishers>
|
||||
<hudson.plugins.jabber.im.transport.JabberPublisher plugin="jabber">
|
||||
<targets/>
|
||||
<strategy>ALL</strategy>
|
||||
<notifyOnBuildStart>false</notifyOnBuildStart>
|
||||
<notifySuspects>false</notifySuspects>
|
||||
<notifyCulprits>false</notifyCulprits>
|
||||
<notifyFixers>false</notifyFixers>
|
||||
<notifyUpstreamCommitters>false</notifyUpstreamCommitters>
|
||||
<buildToChatNotifier class="hudson.plugins.im.build_notify.DefaultBuildToChatNotifier"/>
|
||||
<matrixMultiplier>ONLY_CONFIGURATIONS</matrixMultiplier>
|
||||
</hudson.plugins.jabber.im.transport.JabberPublisher>
|
||||
</publishers>
|
||||
</project>
|
2
tests/publishers/fixtures/jabber-minimal.yaml
Normal file
2
tests/publishers/fixtures/jabber-minimal.yaml
Normal file
@ -0,0 +1,2 @@
|
||||
publishers:
|
||||
- jabber
|
Loading…
Reference in New Issue
Block a user