コード例 #1
0
 /**
  * Sends a message to slack created by information given in the event.
  *
  * @param Event $event
  */
 public function send(Event $event)
 {
     $client = new \Maknz\Slack\Client($this->webhookURL, $this->settings);
     $gotoUrl = "<" . $this->router->generate("bauer_incident_dashboard_core_homepage", array('project' => $event->getEventIdentifier()->getProject()->getIdentifier()), true) . "|Go to Koalamon>";
     if ($event->hasUrl()) {
         $gotoUrl .= "\n<" . $event->getUrl() . "|Go to " . $event->getEventIdentifier()->getTool()->getName() . ">";
     }
     if ($event->getStatus() == Event::STATUS_SUCCESS) {
         $color = self::COLOR_SUCCESS;
         $label = "Your test succeeded (" . $event->getSystem() . ")\nIdentifier: " . $event->getEventIdentifier()->getIdentifier();
         $message = "";
     } else {
         $color = self::COLOR_FAILURE;
         $label = "Your test failed (" . $event->getEventIdentifier()->getSystem()->getName() . ") \nIdentifier: " . $event->getEventIdentifier()->getIdentifier();
         $message = $this->slackifyText($event->getMessage()) . "\n";
     }
     $client->enableMarkdown()->attach(['text' => $message . $gotoUrl, 'color' => $color])->send($label);
 }
コード例 #2
0
 /**
  * Sends a message to slack created by information given in the event.
  *
  * @param Event $event
  */
 public function send(Event $event)
 {
     $payload = ['identifier' => $event->getEventIdentifier()->getIdentifier(), 'system' => $event->getSystem(), 'status' => $event->getStatus(), 'message' => $event->getMessage(), 'type' => $event->getEventIdentifier()->getTool()->getIdentifier(), 'value' => $event->getValue(), 'url' => $event->getUrl(), 'via' => $event->getEventIdentifier()->getProject()->getApiKey()];
     $httpClient = new Client();
     $httpClient->request('POST', $this->webhookURL, ['body' => json_encode($payload)]);
 }