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
|
* **all** -- Always
|
||||||
* **failure** -- On any failure
|
* **failure** -- On any failure
|
||||||
* **failure-fixed** -- On failure and fixes
|
* **failure-fixed** -- On failure and fixes
|
||||||
|
* **new-failure-fixed** -- On new failure and fixes
|
||||||
* **change** -- Only on state change
|
* **change** -- Only on state change
|
||||||
:arg dict message: Channel notification message (default summary-scm)
|
: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-build** -- Summary and build parameters
|
||||||
* **summary-scm-fail** -- Summary, SCM changes, and failed tests
|
* **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
|
:language: yaml
|
||||||
"""
|
"""
|
||||||
j = XML.SubElement(xml_parent, 'hudson.plugins.jabber.im.transport.'
|
j = XML.SubElement(xml_parent, 'hudson.plugins.jabber.im.transport.'
|
||||||
'JabberPublisher')
|
'JabberPublisher')
|
||||||
|
j.set('plugin', 'jabber')
|
||||||
|
|
||||||
t = XML.SubElement(j, 'targets')
|
t = XML.SubElement(j, 'targets')
|
||||||
if 'group-targets' in data:
|
if 'group-targets' in data:
|
||||||
for group in data['group-targets']:
|
for group in data['group-targets']:
|
||||||
gcimt = XML.SubElement(t, 'hudson.plugins.im.'
|
gcimt = XML.SubElement(t, 'hudson.plugins.im.'
|
||||||
'GroupChatIMMessageTarget')
|
'GroupChatIMMessageTarget')
|
||||||
|
gcimt.set('plugin', 'instant-messaging')
|
||||||
XML.SubElement(gcimt, 'name').text = group
|
XML.SubElement(gcimt, 'name').text = group
|
||||||
XML.SubElement(gcimt, 'notificationOnly').text = 'false'
|
XML.SubElement(gcimt, 'notificationOnly').text = 'false'
|
||||||
if 'individual-targets' in data:
|
if 'individual-targets' in data:
|
||||||
for individual in data['individual-targets']:
|
for individual in data['individual-targets']:
|
||||||
dimt = XML.SubElement(t, 'hudson.plugins.im.'
|
dimt = XML.SubElement(t, 'hudson.plugins.im.'
|
||||||
'DefaultIMMessageTarget')
|
'DefaultIMMessageTarget')
|
||||||
|
dimt.set('plugin', 'instant-messaging')
|
||||||
XML.SubElement(dimt, 'value').text = individual
|
XML.SubElement(dimt, 'value').text = individual
|
||||||
strategy = data.get('strategy', 'all')
|
strategy = data.get('strategy', 'all')
|
||||||
strategydict = {'all': 'ALL',
|
strategydict = {'all': 'ALL',
|
||||||
'failure': 'ANY_FAILURE',
|
'failure': 'ANY_FAILURE',
|
||||||
'failure-fixed': 'FAILURE_AND_FIXED',
|
'failure-fixed': 'FAILURE_AND_FIXED',
|
||||||
|
'new-failure-fixed': 'NEW_FAILURE_AND_FIXED',
|
||||||
'change': 'STATECHANGE_ONLY'}
|
'change': 'STATECHANGE_ONLY'}
|
||||||
if strategy not in strategydict:
|
if strategy not in strategydict:
|
||||||
raise JenkinsJobsException("Strategy entered is not valid, must be " +
|
raise JenkinsJobsException("Strategy entered is not valid, must be " +
|
||||||
"one of: all, failure, failure-fixed, or "
|
"one of: all, failure, failure-fixed, or "
|
||||||
"change")
|
"change")
|
||||||
XML.SubElement(j, 'strategy').text = strategydict[strategy]
|
XML.SubElement(j, 'strategy').text = strategydict[strategy]
|
||||||
XML.SubElement(j, 'notifyOnBuildStart').text = str(
|
|
||||||
data.get('notify-on-build-start', False)).lower()
|
mappings = [
|
||||||
XML.SubElement(j, 'notifySuspects').text = str(
|
('notify-on-build-start', 'notifyOnBuildStart', False),
|
||||||
data.get('notify-scm-committers', False)).lower()
|
('notify-scm-committers', 'notifySuspects', False),
|
||||||
XML.SubElement(j, 'notifyCulprits').text = str(
|
('notify-scm-culprits', 'notifyCulprits', False),
|
||||||
data.get('notify-scm-culprits', False)).lower()
|
('notify-scm-fixers', 'notifyFixers', False),
|
||||||
XML.SubElement(j, 'notifyFixers').text = str(
|
('notify-upstream-committers', 'notifyUpstreamCommitters', False)
|
||||||
data.get('notify-scm-fixers', False)).lower()
|
]
|
||||||
XML.SubElement(j, 'notifyUpstreamCommitters').text = str(
|
helpers.convert_mapping_to_xml(j, data, mappings, fail_required=True)
|
||||||
data.get('notify-upstream-committers', False)).lower()
|
|
||||||
message = data.get('message', 'summary-scm')
|
message = data.get('message', 'summary-scm')
|
||||||
messagedict = {'summary-scm': 'DefaultBuildToChatNotifier',
|
messagedict = {'summary-scm': 'DefaultBuildToChatNotifier',
|
||||||
'summary': 'SummaryOnlyBuildToChatNotifier',
|
'summary': 'SummaryOnlyBuildToChatNotifier',
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.plugins.jabber.im.transport.JabberPublisher>
|
<hudson.plugins.jabber.im.transport.JabberPublisher plugin="jabber">
|
||||||
<targets>
|
<targets>
|
||||||
<hudson.plugins.im.GroupChatIMMessageTarget>
|
<hudson.plugins.im.GroupChatIMMessageTarget plugin="instant-messaging">
|
||||||
<name>foo-room@conference-2-fooserver.foo.com</name>
|
<name>foo-room@conference-2-fooserver.foo.com</name>
|
||||||
<notificationOnly>false</notificationOnly>
|
<notificationOnly>false</notificationOnly>
|
||||||
</hudson.plugins.im.GroupChatIMMessageTarget>
|
</hudson.plugins.im.GroupChatIMMessageTarget>
|
||||||
<hudson.plugins.im.DefaultIMMessageTarget>
|
<hudson.plugins.im.DefaultIMMessageTarget plugin="instant-messaging">
|
||||||
<value>foo-user@conference-2-fooserver.foo.com</value>
|
<value>foo-user@conference-2-fooserver.foo.com</value>
|
||||||
</hudson.plugins.im.DefaultIMMessageTarget>
|
</hudson.plugins.im.DefaultIMMessageTarget>
|
||||||
</targets>
|
</targets>
|
||||||
<strategy>ALL</strategy>
|
<strategy>NEW_FAILURE_AND_FIXED</strategy>
|
||||||
<notifyOnBuildStart>true</notifyOnBuildStart>
|
<notifyOnBuildStart>true</notifyOnBuildStart>
|
||||||
<notifySuspects>false</notifySuspects>
|
<notifySuspects>true</notifySuspects>
|
||||||
<notifyCulprits>false</notifyCulprits>
|
<notifyCulprits>true</notifyCulprits>
|
||||||
<notifyFixers>false</notifyFixers>
|
<notifyFixers>true</notifyFixers>
|
||||||
<notifyUpstreamCommitters>false</notifyUpstreamCommitters>
|
<notifyUpstreamCommitters>true</notifyUpstreamCommitters>
|
||||||
<buildToChatNotifier class="hudson.plugins.im.build_notify.DefaultBuildToChatNotifier"/>
|
<buildToChatNotifier class="hudson.plugins.im.build_notify.SummaryOnlyBuildToChatNotifier"/>
|
||||||
<matrixMultiplier>ONLY_CONFIGURATIONS</matrixMultiplier>
|
<matrixMultiplier>ONLY_CONFIGURATIONS</matrixMultiplier>
|
||||||
</hudson.plugins.jabber.im.transport.JabberPublisher>
|
</hudson.plugins.jabber.im.transport.JabberPublisher>
|
||||||
</publishers>
|
</publishers>
|
@ -1,9 +1,13 @@
|
|||||||
publishers:
|
publishers:
|
||||||
- jabber:
|
- jabber:
|
||||||
notify-on-build-start: true
|
notify-on-build-start: true
|
||||||
|
notify-scm-committers: true
|
||||||
|
notify-scm-culprits: true
|
||||||
|
notify-upstream-committers: true
|
||||||
|
notify-scm-fixers: true
|
||||||
group-targets:
|
group-targets:
|
||||||
- "foo-room@conference-2-fooserver.foo.com"
|
- "foo-room@conference-2-fooserver.foo.com"
|
||||||
individual-targets:
|
individual-targets:
|
||||||
- "foo-user@conference-2-fooserver.foo.com"
|
- "foo-user@conference-2-fooserver.foo.com"
|
||||||
strategy: all
|
strategy: new-failure-fixed
|
||||||
message: summary-scm
|
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