From e84a8766fcbc27db696caca073e8d1bf9a73254c Mon Sep 17 00:00:00 2001 From: James Inman Date: Tue, 13 May 2014 16:56:05 +0100 Subject: [PATCH] HipChat integration. --- PHPCI/Plugin/HipchatNotify.php | 63 ++++++++++++++++++++++++++++++++++ composer.json | 3 +- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 PHPCI/Plugin/HipchatNotify.php diff --git a/PHPCI/Plugin/HipchatNotify.php b/PHPCI/Plugin/HipchatNotify.php new file mode 100644 index 000000000..4e9767598 --- /dev/null +++ b/PHPCI/Plugin/HipchatNotify.php @@ -0,0 +1,63 @@ + + * @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); + } + } +} diff --git a/composer.json b/composer.json index 9ccd326b9..3d9a81be3 100644 --- a/composer.json +++ b/composer.json @@ -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" } } \ No newline at end of file