From 2c156b96069972f45720a5222f5d0110aeb482f2 Mon Sep 17 00:00:00 2001 From: Wayne Date: Sat, 7 Feb 2015 15:49:44 -0800 Subject: [PATCH] (hipchat) Accept list of hipchat rooms. Change-Id: I8c840fdebd58ed4dd22c6a5cafa549bfaf5357cf --- jenkins_jobs/modules/hipchat_notif.py | 19 ++++++++++++---- .../fixtures/hipchat_rooms-list001.xml | 22 +++++++++++++++++++ .../fixtures/hipchat_rooms-list001.yaml | 12 ++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 tests/hipchat/fixtures/hipchat_rooms-list001.xml create mode 100644 tests/hipchat/fixtures/hipchat_rooms-list001.yaml diff --git a/jenkins_jobs/modules/hipchat_notif.py b/jenkins_jobs/modules/hipchat_notif.py index f2ef75b87..585ec482c 100644 --- a/jenkins_jobs/modules/hipchat_notif.py +++ b/jenkins_jobs/modules/hipchat_notif.py @@ -22,6 +22,10 @@ Enable HipChat notifications of build execution. 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 + + .. deprecated:: 1.2.0 Please use 'rooms'. + + * **rooms** *(list)*: list of HipChat rooms to post messages to * **start-notify** *(bool)*: post messages about build start event * **notify-success** *(bool)*: post messages about successful build event (Jenkins HipChat plugin >= 0.1.5) @@ -101,9 +105,6 @@ class HipChat(jenkins_jobs.modules.base.Base): hipchat = data.get('hipchat') if not hipchat or not hipchat.get('enabled', True): return - if('room' not in hipchat): - raise jenkins_jobs.errors.YAMLFormatError( - "Missing hipchat 'room' specifier") self._load_global_data() properties = xml_parent.find('properties') @@ -112,7 +113,17 @@ class HipChat(jenkins_jobs.modules.base.Base): pdefhip = XML.SubElement(properties, 'jenkins.plugins.hipchat.' 'HipChatNotifier_-HipChatJobProperty') - XML.SubElement(pdefhip, 'room').text = hipchat['room'] + + room = XML.SubElement(pdefhip, 'room') + if 'rooms' in hipchat: + room.text = ",".join(hipchat['rooms']) + 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.") + XML.SubElement(pdefhip, 'startNotification').text = str( hipchat.get('start-notify', False)).lower() if hipchat.get('notify-success'): diff --git a/tests/hipchat/fixtures/hipchat_rooms-list001.xml b/tests/hipchat/fixtures/hipchat_rooms-list001.xml new file mode 100644 index 000000000..ad8bcb246 --- /dev/null +++ b/tests/hipchat/fixtures/hipchat_rooms-list001.xml @@ -0,0 +1,22 @@ + + + + + My Room,Your Room + true + true + true + true + true + true + true + + + + + url + authtoken + + + + diff --git a/tests/hipchat/fixtures/hipchat_rooms-list001.yaml b/tests/hipchat/fixtures/hipchat_rooms-list001.yaml new file mode 100644 index 000000000..47d23cbac --- /dev/null +++ b/tests/hipchat/fixtures/hipchat_rooms-list001.yaml @@ -0,0 +1,12 @@ +hipchat: + enabled: true + rooms: + - My Room + - Your Room + start-notify: true + notify-success: true + notify-aborted: true + notify-not-built: true + notify-unstable: true + notify-failure: true + notify-back-to-normal: true