diff --git a/PHPCI/Plugin/Deployer.php b/PHPCI/Plugin/Deployer.php new file mode 100644 index 00000000..62f51d0d --- /dev/null +++ b/PHPCI/Plugin/Deployer.php @@ -0,0 +1,66 @@ + +* @package PHPCI +* @subpackage Plugins +*/ +class Deployer implements \PHPCI\Plugin +{ + protected $webhookUrl; + protected $reason; + + /** + * Set up the plugin, configure options, etc. + * @param Builder $phpci + * @param Build $build + * @param array $options + */ + public function __construct(Builder $phpci, Build $build, array $options = array()) + { + $this->phpci = $phpci; + $this->build = $build; + $this->reason = 'PHPCI Build #%BUILD%'; + + if (isset($options['webhook_url'])) { + $this->webhookUrl = $options['webhook_url']; + } + + if (isset($options['reason'])) { + $this->reason = $options['reason']; + } + } + + /** + * Copies files from the root of the build directory into the target folder + */ + public function execute() + { + if (empty($this->webhookUrl)) { + $this->phpci->logFailure('You must specify a webhook URL.'); + return false; + } + + $http = new HttpClient(); + + $response = $http->post($this->webhookUrl, array( + 'reason' => $this->phpci->interpolate($this->reason), + )); + + return $response['success']; + } +}