From 489314cac8cc9a3335535020cd4555ebd15be7d3 Mon Sep 17 00:00:00 2001 From: Dmitrijs Vrublevskis Date: Sun, 29 Jun 2014 15:18:21 +0300 Subject: [PATCH] Add color & notify options for HipChat plugin. Also fix execute result - return correct notify status. --- PHPCI/Plugin/HipchatNotify.php | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/PHPCI/Plugin/HipchatNotify.php b/PHPCI/Plugin/HipchatNotify.php index 4e976759..10d804ef 100644 --- a/PHPCI/Plugin/HipchatNotify.php +++ b/PHPCI/Plugin/HipchatNotify.php @@ -23,6 +23,8 @@ class HipchatNotify implements \PHPCI\Plugin private $authToken; private $userAgent; private $cookie; + private $color; + private $notify; public function __construct(Builder $phpci, Build $build, array $options = array()) { @@ -41,6 +43,18 @@ class HipchatNotify implements \PHPCI\Plugin } else { $this->message = '%PROJECT_TITLE% built at %BUILD_URI%'; } + + if (isset($options['color'])) { + $this->color = $options['color']; + } else { + $this->color = 'yellow'; + } + + if (isset($options['notify'])) { + $this->notify = $options['notify']; + } else { + $this->notify = false; + } } else { throw new \Exception('Please define room and authToken for hipchat_notify plugin!'); } @@ -52,12 +66,19 @@ class HipchatNotify implements \PHPCI\Plugin $hipChat = new \HipChat\HipChat($this->authToken); $message = $this->phpci->interpolate($this->message); + $result = true; if (is_array($this->room)) { foreach ($this->room as $room) { - $hipChat->message_room($room, 'PHPCI', $message); + if (!$hipChat->message_room($room, 'PHPCI', $message, $this->notify, $this->color)) { + $result = false; + } } } else { - $hipChat->message_room($this->room, 'PHPCI', $message); + if (!$hipChat->message_room($this->room, 'PHPCI', $message, $this->notify, $this->color)) { + $result = false; + } } + + return $result; } }