public function execute()
    {
        $body = $this->phpci->interpolate($this->message);

        $client = new \Maknz\Slack\Client($this->webHook);

        $message = $client->createMessage();

        if (!empty($this->room)) {
            $message->setChannel($this->room);
        }

        if (!empty($this->username)) {
            $message->setUsername($this->username);
        }

        if (!empty($this->icon)) {
            $message->setIcon($this->icon);
        }

        // Include an attachment which shows the status and hide the message
        if ($this->show_status) {
            $successfulBuild = $this->build->isSuccessful();

            if ($successfulBuild) {
                $status = 'Success';
                $color = 'good';
            } else {
                $status = 'Failed';
                $color = 'danger';
            }

            // Build up the attachment data
            $attachment = new \Maknz\Slack\Attachment(array(
                'fallback' => $body,
                'pretext'  => $body,
                'color'    => $color,
                'fields'   => array(
                    new \Maknz\Slack\AttachmentField(array(
                        'title' => 'Status',
                        'value' => $status,
                        'short' => false
                    ))
                )
            ));

            $message->attach($attachment);

            $body = '';
        }

        $message->send($body);

        return true;
    }
public function execute()
    {
        $body = $this->phpci->interpolate($this->message);

        $client = new \Maknz\Slack\Client($this->webHook);

        $message = $client->createMessage();

        if (!empty($this->room)) {
            $message->setChannel($this->room);
        }

        if (!empty($this->username)) {
            $message->setUsername($this->username);
        }

        if (!empty($this->icon)) {
            $message->setIcon($this->icon);
        }

        // Include an attachment which shows the status and hide the message
        if ($this->show_status) {
            $successfulBuild = $this->build->isSuccessful();

            if ($successfulBuild) {
                $status = 'Success';
                $color = 'good';
            } else {
                $status = 'Failed';
                $color = 'danger';
            }

            // Build up the attachment data
            $attachment = new \Maknz\Slack\Attachment(array(
                'fallback' => $body,
                'pretext'  => $body,
                'color'    => $color,
                'fields'   => array(
                    new \Maknz\Slack\AttachmentField(array(
                        'title' => 'Status',
                        'value' => $status,
                        'short' => false
                    ))
                )
            ));

            $message->attach($attachment);

            $body = '';
        }

        $message->send($body);

        return true;
    }
public function execute ( ) { $ body = $ this -> phpci -> interpolate ( $ this -> message ) ; $ client = new \ Maknz \ Slack \ Client ( $ this -> webHook ) ; $ message = $ client -> createMessage ( ) ; if ( ! empty ( $ this -> room ) ) { $ message -> setChannel ( $ this -> room ) ; } if ( ! empty ( $ this -> username ) ) { $ message -> setUsername ( $ this -> username ) ; } if ( ! empty ( $ this -> icon ) ) { $ message -> setIcon ( $ this -> icon ) ; } // Include an attachment which shows the status and hide the message if ( $ this -> show_status ) { $ successfulBuild = $ this -> build -> isSuccessful ( ) ; if ( $ successfulBuild ) { $ status = 'Success' ; $ color = 'good' ; } else { $ status = 'Failed' ; $ color = 'danger' ; } // Build up the attachment data $ attachment = new \ Maknz \ Slack \ Attachment ( array ( 'fallback' => $ body , 'pretext' => $ body , 'color' => $ color , 'fields' => array ( new \ Maknz \ Slack \ AttachmentField ( array ( 'title' => 'Status' , 'value' => $ status , 'short' => false ) ) ) ) ) ; $ message -> attach ( $ attachment ) ; $ body = '' ; } $ message -> send ( $ body ) ; return true ; }
Run the Slack plugin.
@return bool
Run the Slack plugin .