Added hipchat publisher for HipChat plugin >=0.1.9

A new hipchat publisher has been added.  It replaces the old hipchat
notifier mechanism for HipChat plugin >=0.1.9

Change-Id: Ifa5e147da77882390d07e1bc9b58abff6f15ac1e
Signed-off-by: Kyle Rockman <kyle.rockman@mac.com>
Co-Authored-By: Richard Pijnenburg <richard.pijnenburg@gmail.com>
This commit is contained in:
Timothy Chavez 2015-09-09 18:54:17 -05:00
parent 832e61224c
commit a18d39a716
4 changed files with 100 additions and 0 deletions

View File

@ -5120,6 +5120,77 @@ def whitesource(parser, xml_parent, data):
XML.SubElement(whitesource, 'ignorePomModules').text = 'false'
def hipchat(parser, xml_parent, data):
"""yaml: hipchat
Publisher that sends hipchat notifications on job events
Requires the Jenkins :jenkins-wiki:`Hipchat Plugin
<Hipchat+Plugin>` version >=1.9
Please see documentation for older plugin version
http://docs.openstack.org/infra/jenkins-job-builder/hipchat.html
:arg str token: This will override the default auth token (optional)
:arg list rooms: list of HipChat rooms to post messages to, overrides
global default (optional)
:arg bool notify-start: post messages about build start event
(default False)
:arg bool notify-success: post messages about successful build event
(default False)
:arg bool notify-aborted: post messages about aborted build event
(default False)
:arg bool notify-not-built: post messages about build set to NOT_BUILT.
This status code is used in a multi-stage build where a problem in
earlier stage prevented later stages from building. (default False)
:arg bool notify-unstable: post messages about unstable build event
(default False)
:arg bool notify-failure: post messages about build failure event
(default False)
:arg bool notify-back-to-normal: post messages about build being back to
normal after being unstable or failed (default False)
:arg str start-message: This will override the default start message
(optional)
:arg str complete-message: This will override the default complete message
(optional)
Example:
.. literalinclude:: /../../tests/publishers/fixtures/hipchat001.yaml
:language: yaml
"""
hipchat = XML.SubElement(
xml_parent,
'jenkins.plugins.hipchat.HipChatNotifier')
XML.SubElement(hipchat, 'token').text = str(
data.get('token', ''))
if 'rooms' in data:
XML.SubElement(hipchat, 'room').text = str(
",".join(data['rooms']))
XML.SubElement(hipchat, 'startNotification').text = str(
data.get('notify-start', False)).lower()
XML.SubElement(hipchat, 'notifySuccess').text = str(
data.get('notify-success', False)).lower()
XML.SubElement(hipchat, 'notifyAborted').text = str(
data.get('notify-aborted', False)).lower()
XML.SubElement(hipchat, 'notifyNotBuilt').text = str(
data.get('notify-not-built', False)).lower()
XML.SubElement(hipchat, 'notifyUnstable').text = str(
data.get('notify-unstable', False)).lower()
XML.SubElement(hipchat, 'notifyFailure').text = str(
data.get('notify-failure', False)).lower()
XML.SubElement(hipchat, 'notifyBackToNormal').text = str(
data.get('notify-back-to-normal', False)).lower()
# optional settings, so only add XML in if set.
if 'start-message' in data:
XML.SubElement(hipchat, 'startJobMessage').text = str(
data['start-message'])
if 'complete-message' in data:
XML.SubElement(hipchat, 'completeJobMessage').text = str(
data['complete-message'])
class Publishers(jenkins_jobs.modules.base.Base):
sequence = 70

View File

@ -173,6 +173,7 @@ jenkins_jobs.publishers =
github-notifier=jenkins_jobs.modules.publishers:github_notifier
google-cloud-storage=jenkins_jobs.modules.publishers:google_cloud_storage
groovy-postbuild=jenkins_jobs.modules.publishers:groovy_postbuild
hipchat=jenkins_jobs.modules.publishers:hipchat
html-publisher=jenkins_jobs.modules.publishers:html_publisher
image-gallery=jenkins_jobs.modules.publishers:image_gallery
ircbot=jenkins_jobs.modules.publishers:ircbot

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<publishers>
<jenkins.plugins.hipchat.HipChatNotifier>
<token>auth</token>
<room>room1,room2</room>
<startNotification>true</startNotification>
<notifySuccess>false</notifySuccess>
<notifyAborted>true</notifyAborted>
<notifyNotBuilt>false</notifyNotBuilt>
<notifyUnstable>false</notifyUnstable>
<notifyFailure>false</notifyFailure>
<notifyBackToNormal>false</notifyBackToNormal>
<startJobMessage>job started</startJobMessage>
<completeJobMessage>job completed</completeJobMessage>
</jenkins.plugins.hipchat.HipChatNotifier>
</publishers>
</project>

View File

@ -0,0 +1,10 @@
publishers:
- hipchat:
token: auth
rooms:
- room1
- room2
notify-start: true
notify-aborted: true
start-message: job started
complete-message: job completed