Merge pull request #470 from FylmTM/feature-hipchat_plugin_customize
HipChat plugin update - color & notify options added.
This commit is contained in:
commit
f82e65eb5e
|
@ -23,6 +23,8 @@ class HipchatNotify implements \PHPCI\Plugin
|
||||||
private $authToken;
|
private $authToken;
|
||||||
private $userAgent;
|
private $userAgent;
|
||||||
private $cookie;
|
private $cookie;
|
||||||
|
private $color;
|
||||||
|
private $notify;
|
||||||
|
|
||||||
public function __construct(Builder $phpci, Build $build, array $options = array())
|
public function __construct(Builder $phpci, Build $build, array $options = array())
|
||||||
{
|
{
|
||||||
|
@ -41,6 +43,18 @@ class HipchatNotify implements \PHPCI\Plugin
|
||||||
} else {
|
} else {
|
||||||
$this->message = '%PROJECT_TITLE% built at %BUILD_URI%';
|
$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 {
|
} else {
|
||||||
throw new \Exception('Please define room and authToken for hipchat_notify plugin!');
|
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);
|
$hipChat = new \HipChat\HipChat($this->authToken);
|
||||||
$message = $this->phpci->interpolate($this->message);
|
$message = $this->phpci->interpolate($this->message);
|
||||||
|
|
||||||
|
$result = true;
|
||||||
if (is_array($this->room)) {
|
if (is_array($this->room)) {
|
||||||
foreach ($this->room as $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 {
|
} else {
|
||||||
$hipChat->message_room($this->room, 'PHPCI', $message);
|
if (!$hipChat->message_room($this->room, 'PHPCI', $message, $this->notify, $this->color)) {
|
||||||
|
$result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue