Skip to content

Commit

Permalink
Merge pull request #419 from jfi/master
Browse files Browse the repository at this point in the history
HipChat integration. Fixes #283
  • Loading branch information
dancryer committed May 13, 2014
2 parents 04a79d0 + e84a876 commit 8089478
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
63 changes: 63 additions & 0 deletions PHPCI/Plugin/HipchatNotify.php
@@ -0,0 +1,63 @@
<?php
/**
* PHPCI - Continuous Integration for PHP
*
* @copyright Copyright 2014, Block 8 Limited.
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
* @link https://www.phptesting.org/
*/

namespace PHPCI\Plugin;

use PHPCI\Builder;
use PHPCI\Model\Build;

/**
* Hipchat Plugin
* @author James Inman <james@jamesinman.co.uk>
* @package PHPCI
* @subpackage Plugins
*/
class HipchatNotify implements \PHPCI\Plugin
{
private $authToken;
private $userAgent;
private $cookie;

public function __construct(Builder $phpci, Build $build, array $options = array())
{
$this->phpci = $phpci;
$this->build = $build;

$this->userAgent = "PHPCI/1.0 (+http://www.phptesting.org/)";
$this->cookie = "phpcicookie";

if (is_array($options) && isset($options['authToken']) && isset($options['room'])) {
$this->authToken = $options['authToken'];
$this->room = $options['room'];

if (isset($options['message'])) {
$this->message = $options['message'];
} else {
$this->message = '%PROJECT_TITLE% built at %BUILD_URI%';
}
} else {
throw new \Exception('Please define room and authToken for hipchat_notify plugin!');
}

}

public function execute()
{
$hipChat = new \HipChat\HipChat($this->authToken);
$message = $this->phpci->interpolate($this->message);

if (is_array($this->room)) {
foreach ($this->room as $room) {
$hipChat->message_room($room, 'PHPCI', $message);
}
} else {
$hipChat->message_room($this->room, 'PHPCI', $message);
}
}
}
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -53,6 +53,7 @@
"phploc/phploc": "PHP Lines of Code",
"atoum/atoum": "Atoum",
"jakub-onderka/php-parallel-lint": "Parallel Linting Tool",
"behat/behat": "Behat BDD Testing"
"behat/behat": "Behat BDD Testing",
"hipchat/hipchat-php": "Hipchat integration"
}
}

0 comments on commit 8089478

Please sign in to comment.