Update ircbot plugin
- update ircbot plugin to convert xml - update docstring - add plugin='ircbot' attribute - update test cases Change-Id: I3d061a5b5d0dd0315a019703c6b269c80a8fdec6
This commit is contained in:
parent
bd0c1f33b8
commit
9a6aea1ca1
jenkins_jobs/modules
tests/publishers/fixtures
@ -4070,21 +4070,16 @@ def ircbot(registry, xml_parent, data):
|
|||||||
* **new-failure-and-fixed** on new failure and fixes
|
* **new-failure-and-fixed** on new failure and fixes
|
||||||
* **statechange-only** only on state change
|
* **statechange-only** only on state change
|
||||||
:arg bool notify-start: Whether to send notifications to channels when a
|
:arg bool notify-start: Whether to send notifications to channels when a
|
||||||
build starts
|
build starts (default false)
|
||||||
(default false)
|
|
||||||
:arg bool notify-committers: Whether to send notifications to the users
|
:arg bool notify-committers: Whether to send notifications to the users
|
||||||
that are suspected of having broken this build
|
that are suspected of having broken this build (default false)
|
||||||
(default false)
|
|
||||||
:arg bool notify-culprits: Also send notifications to 'culprits' from
|
:arg bool notify-culprits: Also send notifications to 'culprits' from
|
||||||
previous unstable/failed builds
|
previous unstable/failed builds (default false)
|
||||||
(default false)
|
|
||||||
:arg bool notify-upstream: Whether to send notifications to upstream
|
:arg bool notify-upstream: Whether to send notifications to upstream
|
||||||
committers if no committers were found for a
|
committers if no committers were found for a broken build
|
||||||
broken build
|
|
||||||
(default false)
|
(default false)
|
||||||
:arg bool notify-fixers: Whether to send notifications to the users that
|
:arg bool notify-fixers: Whether to send notifications to the users that
|
||||||
have fixed a broken build
|
have fixed a broken build (default false)
|
||||||
(default false)
|
|
||||||
:arg string message-type: Channel Notification Message.
|
:arg string message-type: Channel Notification Message.
|
||||||
|
|
||||||
:message-type values:
|
:message-type values:
|
||||||
@ -4095,9 +4090,9 @@ def ircbot(registry, xml_parent, data):
|
|||||||
:arg list channels: list channels definitions
|
:arg list channels: list channels definitions
|
||||||
If empty, it takes channel from Jenkins configuration.
|
If empty, it takes channel from Jenkins configuration.
|
||||||
(default empty)
|
(default empty)
|
||||||
WARNING: the IRC plugin requires the channel to be
|
WARNING: the IRC plugin requires the channel to be configured in the
|
||||||
configured in the system wide configuration or the jobs
|
system wide configuration or the jobs will fail to emit notifications
|
||||||
will fail to emit notifications to the channel
|
to the channel
|
||||||
|
|
||||||
:Channel: * **name** (`str`) Channel name
|
:Channel: * **name** (`str`) Channel name
|
||||||
* **password** (`str`) Channel password (optional)
|
* **password** (`str`) Channel password (optional)
|
||||||
@ -4113,12 +4108,18 @@ def ircbot(registry, xml_parent, data):
|
|||||||
* **only-configurations** (default)
|
* **only-configurations** (default)
|
||||||
* **only-parent**
|
* **only-parent**
|
||||||
|
|
||||||
Example:
|
Minimal Example:
|
||||||
|
|
||||||
.. literalinclude:: /../../tests/publishers/fixtures/ircbot001.yaml
|
.. literalinclude:: /../../tests/publishers/fixtures/ircbot-minimal.yaml
|
||||||
|
:language: yaml
|
||||||
|
|
||||||
|
Full Example:
|
||||||
|
|
||||||
|
.. literalinclude:: /../../tests/publishers/fixtures/ircbot-full.yaml
|
||||||
:language: yaml
|
:language: yaml
|
||||||
"""
|
"""
|
||||||
top = XML.SubElement(xml_parent, 'hudson.plugins.ircbot.IrcPublisher')
|
top = XML.SubElement(xml_parent, 'hudson.plugins.ircbot.IrcPublisher')
|
||||||
|
top.set('plugin', 'ircbot')
|
||||||
message_dict = {'summary-scm': 'DefaultBuildToChatNotifier',
|
message_dict = {'summary-scm': 'DefaultBuildToChatNotifier',
|
||||||
'summary': 'SummaryOnlyBuildToChatNotifier',
|
'summary': 'SummaryOnlyBuildToChatNotifier',
|
||||||
'summary-params': 'BuildParametersBuildToChatNotifier',
|
'summary-params': 'BuildParametersBuildToChatNotifier',
|
||||||
@ -4130,45 +4131,39 @@ def ircbot(registry, xml_parent, data):
|
|||||||
", ".join(message_dict.keys()))
|
", ".join(message_dict.keys()))
|
||||||
message = "hudson.plugins.im.build_notify." + message_dict.get(message)
|
message = "hudson.plugins.im.build_notify." + message_dict.get(message)
|
||||||
XML.SubElement(top, 'buildToChatNotifier', attrib={'class': message})
|
XML.SubElement(top, 'buildToChatNotifier', attrib={'class': message})
|
||||||
strategy_dict = {'all': 'ALL',
|
|
||||||
'any-failure': 'ANY_FAILURE',
|
|
||||||
'failure-and-fixed': 'FAILURE_AND_FIXED',
|
|
||||||
'new-failure-and-fixed': 'NEW_FAILURE_AND_FIXED',
|
|
||||||
'statechange-only': 'STATECHANGE_ONLY'}
|
|
||||||
strategy = data.get('strategy', 'all')
|
|
||||||
if strategy not in strategy_dict:
|
|
||||||
raise JenkinsJobsException("strategy entered is not valid, must be "
|
|
||||||
"one of: %s" %
|
|
||||||
", ".join(strategy_dict.keys()))
|
|
||||||
XML.SubElement(top, 'strategy').text = strategy_dict.get(strategy)
|
|
||||||
targets = XML.SubElement(top, 'targets')
|
targets = XML.SubElement(top, 'targets')
|
||||||
channels = data.get('channels', [])
|
channels = data.get('channels', [])
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
sub = XML.SubElement(targets,
|
sub = XML.SubElement(targets,
|
||||||
'hudson.plugins.im.GroupChatIMMessageTarget')
|
'hudson.plugins.im.GroupChatIMMessageTarget')
|
||||||
XML.SubElement(sub, 'name').text = channel.get('name')
|
sub_mappings = [
|
||||||
XML.SubElement(sub, 'password').text = channel.get('password')
|
('name', 'name', ''),
|
||||||
XML.SubElement(sub, 'notificationOnly').text = str(
|
('password', 'password', ''),
|
||||||
channel.get('notify-only', False)).lower()
|
('notify-only', 'notificationOnly', False)
|
||||||
XML.SubElement(top, 'notifyOnBuildStart').text = str(
|
]
|
||||||
data.get('notify-start', False)).lower()
|
helpers.convert_mapping_to_xml(
|
||||||
XML.SubElement(top, 'notifySuspects').text = str(
|
sub, channel, sub_mappings, fail_required=True)
|
||||||
data.get('notify-committers', False)).lower()
|
strategy_dict = {'all': 'ALL',
|
||||||
XML.SubElement(top, 'notifyCulprits').text = str(
|
'any-failure': 'ANY_FAILURE',
|
||||||
data.get('notify-culprits', False)).lower()
|
'failure-and-fixed': 'FAILURE_AND_FIXED',
|
||||||
XML.SubElement(top, 'notifyFixers').text = str(
|
'new-failure-and-fixed': 'NEW_FAILURE_AND_FIXED',
|
||||||
data.get('notify-fixers', False)).lower()
|
'statechange-only': 'STATECHANGE_ONLY'}
|
||||||
XML.SubElement(top, 'notifyUpstreamCommitters').text = str(
|
|
||||||
data.get('notify-upstream', False)).lower()
|
|
||||||
matrix_dict = {'all': 'ALL',
|
matrix_dict = {'all': 'ALL',
|
||||||
'only-configurations': 'ONLY_CONFIGURATIONS',
|
'only-configurations': 'ONLY_CONFIGURATIONS',
|
||||||
'only-parent': 'ONLY_PARENT'}
|
'only-parent': 'ONLY_PARENT'}
|
||||||
matrix = data.get('matrix-notifier', 'only-configurations')
|
mappings = [
|
||||||
if matrix not in matrix_dict:
|
('strategy', 'strategy', 'all', strategy_dict),
|
||||||
raise JenkinsJobsException("matrix-notifier entered is not valid, "
|
('notify-start', 'notifyOnBuildStart', False),
|
||||||
"must be one of: %s" %
|
('notify-committers', 'notifySuspects', False),
|
||||||
", ".join(matrix_dict.keys()))
|
('notify-culprits', 'notifyCulprits', False),
|
||||||
XML.SubElement(top, 'matrixMultiplier').text = matrix_dict.get(matrix)
|
('notify-fixers', 'notifyFixers', False),
|
||||||
|
('notify-upstream', 'notifyUpstreamCommitters', False),
|
||||||
|
('matrix-notifier',
|
||||||
|
'matrixMultiplier',
|
||||||
|
'only-configurations',
|
||||||
|
matrix_dict)
|
||||||
|
]
|
||||||
|
helpers.convert_mapping_to_xml(top, data, mappings, fail_required=True)
|
||||||
|
|
||||||
|
|
||||||
def plot(registry, xml_parent, data):
|
def plot(registry, xml_parent, data):
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.plugins.ircbot.IrcPublisher>
|
<hudson.plugins.ircbot.IrcPublisher plugin="ircbot">
|
||||||
<buildToChatNotifier class="hudson.plugins.im.build_notify.DefaultBuildToChatNotifier"/>
|
<buildToChatNotifier class="hudson.plugins.im.build_notify.SummaryOnlyBuildToChatNotifier"/>
|
||||||
<strategy>ALL</strategy>
|
|
||||||
<targets>
|
<targets>
|
||||||
<hudson.plugins.im.GroupChatIMMessageTarget>
|
<hudson.plugins.im.GroupChatIMMessageTarget>
|
||||||
<name>#jenkins-channel1</name>
|
<name>#jenkins-channel1</name>
|
||||||
@ -16,12 +15,13 @@
|
|||||||
<notificationOnly>true</notificationOnly>
|
<notificationOnly>true</notificationOnly>
|
||||||
</hudson.plugins.im.GroupChatIMMessageTarget>
|
</hudson.plugins.im.GroupChatIMMessageTarget>
|
||||||
</targets>
|
</targets>
|
||||||
<notifyOnBuildStart>false</notifyOnBuildStart>
|
<strategy>FAILURE_AND_FIXED</strategy>
|
||||||
<notifySuspects>false</notifySuspects>
|
<notifyOnBuildStart>true</notifyOnBuildStart>
|
||||||
<notifyCulprits>false</notifyCulprits>
|
<notifySuspects>true</notifySuspects>
|
||||||
<notifyFixers>false</notifyFixers>
|
<notifyCulprits>true</notifyCulprits>
|
||||||
<notifyUpstreamCommitters>false</notifyUpstreamCommitters>
|
<notifyFixers>true</notifyFixers>
|
||||||
<matrixMultiplier>ONLY_CONFIGURATIONS</matrixMultiplier>
|
<notifyUpstreamCommitters>true</notifyUpstreamCommitters>
|
||||||
|
<matrixMultiplier>ALL</matrixMultiplier>
|
||||||
</hudson.plugins.ircbot.IrcPublisher>
|
</hudson.plugins.ircbot.IrcPublisher>
|
||||||
</publishers>
|
</publishers>
|
||||||
</project>
|
</project>
|
16
tests/publishers/fixtures/ircbot-full.yaml
Normal file
16
tests/publishers/fixtures/ircbot-full.yaml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
publishers:
|
||||||
|
- ircbot:
|
||||||
|
strategy: failure-and-fixed
|
||||||
|
notify-start: true
|
||||||
|
notify-committers: true
|
||||||
|
notify-culprits: true
|
||||||
|
notify-upstream: true
|
||||||
|
notify-fixers: true
|
||||||
|
message-type: summary
|
||||||
|
channels:
|
||||||
|
- name: '#jenkins-channel1'
|
||||||
|
password: secrete
|
||||||
|
notify-only: false
|
||||||
|
- name: '#jenkins-channel2'
|
||||||
|
notify-only: true
|
||||||
|
matrix-notifier: all
|
@ -1,16 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<project>
|
<project>
|
||||||
<publishers>
|
<publishers>
|
||||||
<hudson.plugins.ircbot.IrcPublisher>
|
<hudson.plugins.ircbot.IrcPublisher plugin="ircbot">
|
||||||
<buildToChatNotifier class="hudson.plugins.im.build_notify.DefaultBuildToChatNotifier"/>
|
<buildToChatNotifier class="hudson.plugins.im.build_notify.DefaultBuildToChatNotifier"/>
|
||||||
|
<targets/>
|
||||||
<strategy>ALL</strategy>
|
<strategy>ALL</strategy>
|
||||||
<targets>
|
|
||||||
<hudson.plugins.im.GroupChatIMMessageTarget>
|
|
||||||
<name>#jenkins-channel</name>
|
|
||||||
<password/>
|
|
||||||
<notificationOnly>true</notificationOnly>
|
|
||||||
</hudson.plugins.im.GroupChatIMMessageTarget>
|
|
||||||
</targets>
|
|
||||||
<notifyOnBuildStart>false</notifyOnBuildStart>
|
<notifyOnBuildStart>false</notifyOnBuildStart>
|
||||||
<notifySuspects>false</notifySuspects>
|
<notifySuspects>false</notifySuspects>
|
||||||
<notifyCulprits>false</notifyCulprits>
|
<notifyCulprits>false</notifyCulprits>
|
2
tests/publishers/fixtures/ircbot-minimal.yaml
Normal file
2
tests/publishers/fixtures/ircbot-minimal.yaml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
publishers:
|
||||||
|
- ircbot
|
@ -1,16 +0,0 @@
|
|||||||
publishers:
|
|
||||||
- ircbot:
|
|
||||||
strategy: all
|
|
||||||
notify-start: false
|
|
||||||
notify-committers: false
|
|
||||||
notify-culprits: false
|
|
||||||
notify-upstream: false
|
|
||||||
notify-fixers: false
|
|
||||||
message-type: summary-scm
|
|
||||||
channels:
|
|
||||||
- name: '#jenkins-channel1'
|
|
||||||
password: secrete
|
|
||||||
notify-only: false
|
|
||||||
- name: '#jenkins-channel2'
|
|
||||||
notify-only: true
|
|
||||||
matrix-notifier: only-configurations
|
|
@ -1,5 +0,0 @@
|
|||||||
publishers:
|
|
||||||
- ircbot:
|
|
||||||
channels:
|
|
||||||
- name: '#jenkins-channel'
|
|
||||||
notify-only: true
|
|
Loading…
x
Reference in New Issue
Block a user