コード例 #1
0
ファイル: ErrorHandler.php プロジェクト: grrr-amsterdam/garp3
 /**
  * Log error to Slack.
  * Parameter is expected to be an ArrayObject as formatted by
  * Zend_Controller_Plugin_ErrorHandler::_handleError
  *
  * @param ArrayObject $errors
  * @return bool
  */
 public static function logErrorToSlack(ArrayObject $errors)
 {
     try {
         $slack = new Garp_Service_Slack();
     } catch (Exception $e) {
         return false;
     }
     $shortErrorMessage = self::_composeShortErrorMessage($errors);
     //  Add first occurrence and StackTrace as attachments
     $trace = self::_filterBasePath(str_replace('->', '::', $errors->exception->getTraceAsString()));
     $params['attachments'] = array(array('title' => self::_getExceptionClass($errors), 'text' => $slack->wrapCodeMarkup($errors->exception->getMessage() . "\n" . self::_filterBasePath($errors->exception->getFile()) . ': ' . $errors->exception->getLine()), 'color' => '#bb5555', 'mrkdwn_in' => array('text'), 'short' => true), array('title' => 'StackTrace', 'text' => $slack->wrapCodeMarkup($trace), 'color' => '#6666ee', 'mrkdwn_in' => array('text'), 'short' => true));
     $slack->postMessage($shortErrorMessage, $params);
     return true;
 }
コード例 #2
0
ファイル: Slack.php プロジェクト: grrr-amsterdam/garp3
 /**
  * Send a nicely formatted deploy notification.
  * Note: branch and user are given by Capistrano. The user corresponds to the ssh user used to
  * login to the server, not the Git user.
  *
  * @param array $args
  * @return bool
  */
 public function sendDeployNotification(array $args = array())
 {
     $branch = array_get($args, 'branch', 'unknown');
     $user = array_get($args, 'user', 'unknown');
     $config = Zend_Registry::get('config');
     $appName = $config->app->name;
     $version = new Garp_Semver();
     $env = APPLICATION_ENV;
     $slackParams = $config->slack->toArray();
     $slackParams['icon_emoji'] = ':rocket:';
     $slackConfig = new Garp_Service_Slack_Config($slackParams);
     $slack = new Garp_Service_Slack($slackConfig);
     return $slack->postMessage('', array('attachments' => array(array('pretext' => "{$appName} was deployed to the {$env} server", 'color' => '#7CD197', 'fields' => array(array('title' => 'User', 'value' => ucfirst($user), 'short' => false), array('title' => 'Version', 'value' => (string) $version, 'short' => false), array('title' => 'Environment', 'value' => $env, 'short' => false), array('title' => 'Branch', 'value' => $branch, 'short' => false), array('title' => 'Website', 'value' => (string) new Garp_Util_FullUrl('/'), 'short' => false))))));
 }
コード例 #3
0
ファイル: Gumball.php プロジェクト: grrr-amsterdam/garp3
 protected function _broadcastToSlack($version)
 {
     $slack = new Garp_Service_Slack();
     $slack->postMessage('', array('attachments' => array(array('pretext' => 'A new gumball was deployed', 'color' => '#7CD197', 'fields' => array(array('title' => 'Project', 'value' => Zend_Registry::get('config')->app->name, 'short' => false), array('title' => 'Environment', 'value' => APPLICATION_ENV, 'short' => false), array('title' => 'Version', 'value' => (string) $version, 'short' => false))))));
 }