hipchat bug fix
the current implementation of the hipchat notification types is buggy on updates because it never sets previously enabled types back to false if they are not specified in the yaml anymore but were once true. also room can be blank so it will use the default room as configured in the master jenkins configuration also standardize the notify-* arguments even if jenkins plugin is bad about it Change-Id: I02547fb6474b66a4f3d21ec3bf766334c66cf14c Signed-off-by: Kyle Rockman <kyle.rockman@mac.com>
This commit is contained in:
parent
2c156b9606
commit
295ed05bd0
@ -21,26 +21,33 @@ Enable HipChat notifications of build execution.
|
||||
plugin of version prior to 0.1.5, also enables all build results to be
|
||||
reported in HipChat room. For later plugin versions, explicit notify-*
|
||||
setting is required (see below).
|
||||
* **room** *(str)*: name of HipChat room to post messages to
|
||||
* **room** *(str)*: name of HipChat room to post messages to (default '')
|
||||
|
||||
.. deprecated:: 1.2.0 Please use 'rooms'.
|
||||
|
||||
* **rooms** *(list)*: list of HipChat rooms to post messages to
|
||||
(default empty)
|
||||
* **start-notify** *(bool)*: post messages about build start event
|
||||
|
||||
.. deprecated:: 1.2.0 use notify-start parameter instead
|
||||
|
||||
* **notify-start** *(bool)*: post messages about build start event
|
||||
(default false)
|
||||
* **notify-success** *(bool)*: post messages about successful build event
|
||||
(Jenkins HipChat plugin >= 0.1.5)
|
||||
(Jenkins HipChat plugin >= 0.1.5) (default false)
|
||||
* **notify-aborted** *(bool)*: post messages about aborted build event
|
||||
(Jenkins HipChat plugin >= 0.1.5)
|
||||
(Jenkins HipChat plugin >= 0.1.5) (default false)
|
||||
* **notify-not-built** *(bool)*: post messages about build set to NOT_BUILT
|
||||
status (Jenkins HipChat plugin >= 0.1.5). This status code is used in a
|
||||
multi-stage build (like maven2) where a problem in earlier stage prevented
|
||||
later stages from building.
|
||||
later stages from building. (default false)
|
||||
* **notify-unstable** *(bool)*: post messages about unstable build event
|
||||
(Jenkins HipChat plugin >= 0.1.5)
|
||||
(Jenkins HipChat plugin >= 0.1.5) (default false)
|
||||
* **notify-failure** *(bool)*: post messages about build failure event
|
||||
(Jenkins HipChat plugin >= 0.1.5)
|
||||
(Jenkins HipChat plugin >= 0.1.5) (default false)
|
||||
* **notify-back-to-normal** *(bool)*: post messages about build being back to
|
||||
normal after being unstable or failed (Jenkins HipChat plugin >= 0.1.5)
|
||||
(default false)
|
||||
|
||||
Example:
|
||||
|
||||
@ -107,6 +114,9 @@ class HipChat(jenkins_jobs.modules.base.Base):
|
||||
return
|
||||
self._load_global_data()
|
||||
|
||||
plugin_info = self.registry.get_plugin_info("Jenkins HipChat Plugin")
|
||||
version = pkg_resources.parse_version(plugin_info.get('version', '0'))
|
||||
|
||||
properties = xml_parent.find('properties')
|
||||
if properties is None:
|
||||
properties = XML.SubElement(xml_parent, 'properties')
|
||||
@ -120,30 +130,29 @@ class HipChat(jenkins_jobs.modules.base.Base):
|
||||
elif 'room' in hipchat:
|
||||
logger.warn("'room' is deprecated, please use 'rooms'")
|
||||
room.text = hipchat['room']
|
||||
else:
|
||||
raise jenkins_jobs.errors.YAMLFormatError(
|
||||
"Must specify either 'room' or 'rooms' in hipchat config.")
|
||||
|
||||
# Handle backwards compatibility 'start-notify' but all add an element
|
||||
# of standardization with notify-*
|
||||
if hipchat.get('start-notify'):
|
||||
logger.warn("'start-notify' is deprecated, please use "
|
||||
"'notify-start'")
|
||||
XML.SubElement(pdefhip, 'startNotification').text = str(
|
||||
hipchat.get('start-notify', False)).lower()
|
||||
if hipchat.get('notify-success'):
|
||||
hipchat.get('notify-start', hipchat.get('start-notify',
|
||||
False))).lower()
|
||||
|
||||
if version >= pkg_resources.parse_version("0.1.5"):
|
||||
XML.SubElement(pdefhip, 'notifySuccess').text = str(
|
||||
hipchat.get('notify-success')).lower()
|
||||
if hipchat.get('notify-aborted'):
|
||||
hipchat.get('notify-success', False)).lower()
|
||||
XML.SubElement(pdefhip, 'notifyAborted').text = str(
|
||||
hipchat.get('notify-aborted')).lower()
|
||||
if hipchat.get('notify-not-built'):
|
||||
hipchat.get('notify-aborted', False)).lower()
|
||||
XML.SubElement(pdefhip, 'notifyNotBuilt').text = str(
|
||||
hipchat.get('notify-not-built')).lower()
|
||||
if hipchat.get('notify-unstable'):
|
||||
hipchat.get('notify-not-built', False)).lower()
|
||||
XML.SubElement(pdefhip, 'notifyUnstable').text = str(
|
||||
hipchat.get('notify-unstable')).lower()
|
||||
if hipchat.get('notify-failure'):
|
||||
hipchat.get('notify-unstable', False)).lower()
|
||||
XML.SubElement(pdefhip, 'notifyFailure').text = str(
|
||||
hipchat.get('notify-failure')).lower()
|
||||
if hipchat.get('notify-back-to-normal'):
|
||||
hipchat.get('notify-failure', False)).lower()
|
||||
XML.SubElement(pdefhip, 'notifyBackToNormal').text = str(
|
||||
hipchat.get('notify-back-to-normal')).lower()
|
||||
hipchat.get('notify-back-to-normal', False)).lower()
|
||||
|
||||
publishers = xml_parent.find('publishers')
|
||||
if publishers is None:
|
||||
@ -151,9 +160,6 @@ class HipChat(jenkins_jobs.modules.base.Base):
|
||||
hippub = XML.SubElement(publishers,
|
||||
'jenkins.plugins.hipchat.HipChatNotifier')
|
||||
|
||||
plugin_info = self.registry.get_plugin_info("Jenkins HipChat Plugin")
|
||||
version = pkg_resources.parse_version(plugin_info.get('version', '0'))
|
||||
|
||||
if version >= pkg_resources.parse_version("0.1.8"):
|
||||
XML.SubElement(hippub, 'buildServerUrl').text = self.jenkinsUrl
|
||||
XML.SubElement(hippub, 'sendAs').text = self.sendAs
|
||||
|
6
tests/hipchat/fixtures/hipchat001.plugins_info.yaml
Normal file
6
tests/hipchat/fixtures/hipchat001.plugins_info.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
- longName: 'Jenkins HipChat Plugin'
|
||||
shortName: 'hipchat'
|
||||
version: "0.1.5"
|
||||
- longName: 'Derp HipChat Plugin'
|
||||
shortName: 'hipchat'
|
||||
version: "0.1.0"
|
@ -1,7 +1,7 @@
|
||||
hipchat:
|
||||
enabled: true
|
||||
room: My Room
|
||||
start-notify: true
|
||||
notify-start: true
|
||||
notify-success: true
|
||||
notify-aborted: true
|
||||
notify-not-built: true
|
||||
|
@ -2,7 +2,7 @@
|
||||
<project>
|
||||
<properties>
|
||||
<jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty>
|
||||
<room>My Room</room>
|
||||
<room/>
|
||||
<startNotification>true</startNotification>
|
||||
</jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty>
|
||||
</properties>
|
||||
|
@ -1,4 +1,3 @@
|
||||
hipchat:
|
||||
enabled: true
|
||||
room: My Room
|
||||
start-notify: true
|
||||
notify-start: true
|
||||
|
6
tests/hipchat/fixtures/hipchat004.plugins_info.yaml
Normal file
6
tests/hipchat/fixtures/hipchat004.plugins_info.yaml
Normal file
@ -0,0 +1,6 @@
|
||||
- longName: 'Jenkins HipChat Plugin'
|
||||
shortName: 'hipchat'
|
||||
version: "0.1.8"
|
||||
- longName: 'Derp HipChat Plugin'
|
||||
shortName: 'hipchat'
|
||||
version: "0.1.0"
|
23
tests/hipchat/fixtures/hipchat004.xml
Normal file
23
tests/hipchat/fixtures/hipchat004.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<project>
|
||||
<properties>
|
||||
<jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty>
|
||||
<room/>
|
||||
<startNotification>true</startNotification>
|
||||
<notifySuccess>false</notifySuccess>
|
||||
<notifyAborted>false</notifyAborted>
|
||||
<notifyNotBuilt>false</notifyNotBuilt>
|
||||
<notifyUnstable>false</notifyUnstable>
|
||||
<notifyFailure>false</notifyFailure>
|
||||
<notifyBackToNormal>false</notifyBackToNormal>
|
||||
</jenkins.plugins.hipchat.HipChatNotifier_-HipChatJobProperty>
|
||||
</properties>
|
||||
<publishers>
|
||||
<jenkins.plugins.hipchat.HipChatNotifier>
|
||||
<buildServerUrl>url</buildServerUrl>
|
||||
<sendAs>send-as</sendAs>
|
||||
<authToken>authtoken</authToken>
|
||||
<room/>
|
||||
</jenkins.plugins.hipchat.HipChatNotifier>
|
||||
</publishers>
|
||||
</project>
|
3
tests/hipchat/fixtures/hipchat004.yaml
Normal file
3
tests/hipchat/fixtures/hipchat004.yaml
Normal file
@ -0,0 +1,3 @@
|
||||
hipchat:
|
||||
enabled: true
|
||||
notify-start: true
|
@ -0,0 +1,6 @@
|
||||
- longName: 'Jenkins HipChat Plugin'
|
||||
shortName: 'hipchat'
|
||||
version: "0.1.8"
|
||||
- longName: 'Derp HipChat Plugin'
|
||||
shortName: 'hipchat'
|
||||
version: "0.1.0"
|
@ -14,7 +14,8 @@
|
||||
</properties>
|
||||
<publishers>
|
||||
<jenkins.plugins.hipchat.HipChatNotifier>
|
||||
<jenkinsUrl>url</jenkinsUrl>
|
||||
<buildServerUrl>url</buildServerUrl>
|
||||
<sendAs>send-as</sendAs>
|
||||
<authToken>authtoken</authToken>
|
||||
<room/>
|
||||
</jenkins.plugins.hipchat.HipChatNotifier>
|
||||
|
Loading…
x
Reference in New Issue
Block a user