/**
  * Triggers Jenkins Build for the project
  */
 public function execute()
 {
     $success = true;
     if ($this->build->isSuccessful()) {
         // Builds the Jenkins trigger
         $jenkins = $this->jenkinsUrl . '/job/' . rawurlencode($this->jenkinsProject) . '/build?delay=0sec';
         if ($this->jenkinsToken && !empty($this->jenkinsToken)) {
             $jenkins .= '&token=%s';
         }
         $jenkins = sprintf($jenkins, rawurlencode($this->jenkinsProject), $this->jenkinsToken);
         $this->phpci->log($jenkins);
         $curlHandler = curl_init($jenkins);
         curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, 1);
         curl_exec($curlHandler);
         $status = curl_getinfo($curlHandler, CURLINFO_HTTP_CODE);
         $curlUrl = curl_getinfo($curlHandler, CURLINFO_EFFECTIVE_URL);
         curl_close($curlHandler);
         if ($status != '200') {
             $this->phpci->logFailure($curlUrl . ' return with status code ' . $status);
             return false;
         }
     } else {
         $this->phpci->log('Skipping due to failed Build');
     }
     return $success;
 }
示例#2
0
 /**
  * Send a notification mail.
  */
 public function execute()
 {
     $addresses = $this->getEmailAddresses();
     // Without some email addresses in the yml file then we
     // can't do anything.
     if (count($addresses) == 0) {
         return false;
     }
     $buildStatus = $this->build->isSuccessful() ? "Passing Build" : "Failing Build";
     $projectName = $this->build->getProject()->getTitle();
     try {
         $view = $this->getMailTemplate();
     } catch (Exception $e) {
         $this->phpci->log(sprintf('Unknown mail template "%s", falling back to default.', $this->options['template']), LogLevel::WARNING);
         $view = $this->getDefaultMailTemplate();
     }
     $view->build = $this->build;
     $view->project = $this->build->getProject();
     $layout = new View('Email/layout');
     $layout->build = $this->build;
     $layout->project = $this->build->getProject();
     $layout->content = $view->render();
     $body = $layout->render();
     $sendFailures = $this->sendSeparateEmails($addresses, sprintf("PHPCI - %s - %s", $projectName, $buildStatus), $body);
     // This is a success if we've not failed to send anything.
     $this->phpci->log(sprintf("%d emails sent", count($addresses) - $sendFailures));
     $this->phpci->log(sprintf("%d emails failed to send", $sendFailures));
     return $sendFailures === 0;
 }
示例#3
0
文件: Email.php 项目: kukupigs/PHPCI
 /**
  * Connects to MySQL and runs a specified set of queries.
  */
 public function execute()
 {
     $addresses = $this->getEmailAddresses();
     // Without some email addresses in the yml file then we
     // can't do anything.
     if (count($addresses) == 0) {
         return false;
     }
     $subjectTemplate = "PHPCI - %s - %s";
     $projectName = $this->phpci->getBuildProjectTitle();
     $logText = $this->build->getLog();
     if ($this->build->isSuccessful()) {
         $sendFailures = $this->sendSeparateEmails($addresses, sprintf($subjectTemplate, $projectName, "Passing Build"), sprintf("Log Output: <br><pre>%s</pre>", $logText));
     } else {
         $view = new View('Email/failed');
         $view->build = $this->build;
         $view->project = $this->build->getProject();
         $emailHtml = $view->render();
         $sendFailures = $this->sendSeparateEmails($addresses, sprintf($subjectTemplate, $projectName, "Failing Build"), $emailHtml);
     }
     // This is a success if we've not failed to send anything.
     $this->phpci->log(sprintf("%d emails sent", count($addresses) - count($sendFailures)));
     $this->phpci->log(sprintf("%d emails failed to send", count($sendFailures)));
     return count($sendFailures) == 0;
 }
示例#4
0
文件: Pdepend.php 项目: mrudtf/PHPCI
 /**
  * Runs Pdepend with the given criteria as arguments
  */
 public function execute()
 {
     if (!is_writable($this->location)) {
         throw new \Exception(sprintf('The location %s is not writable.', $this->location));
     }
     $pdepend = $this->phpci->findBinary('pdepend');
     if (!$pdepend) {
         $this->phpci->logFailure(Lang::get('could_not_find', 'pdepend'));
         return false;
     }
     $cmd = $pdepend . ' --summary-xml="%s" --jdepend-chart="%s" --overview-pyramid="%s" %s "%s"';
     $this->removeBuildArtifacts();
     // If we need to ignore directories
     if (count($this->phpci->ignore)) {
         $ignore = ' --ignore=' . implode(',', $this->phpci->ignore);
     } else {
         $ignore = '';
     }
     $success = $this->phpci->executeCommand($cmd, $this->location . DIRECTORY_SEPARATOR . $this->summary, $this->location . DIRECTORY_SEPARATOR . $this->chart, $this->location . DIRECTORY_SEPARATOR . $this->pyramid, $ignore, $this->directory);
     $config = $this->phpci->getSystemConfig('phpci');
     if ($success) {
         $this->phpci->logSuccess(sprintf("Pdepend successful. You can use %s\n, ![Chart](%s \"Pdepend Chart\")\n\n                    and ![Pyramid](%s \"Pdepend Pyramid\")\n\n                    for inclusion in the readme.md file", $config['url'] . '/build/pdepend/' . $this->summary, $config['url'] . '/build/pdepend/' . $this->chart, $config['url'] . '/build/pdepend/' . $this->pyramid));
     }
     return $success;
 }
示例#5
0
文件: PhpSpec.php 项目: mrudtf/PHPCI
 /**
  * Runs PHP Spec tests.
  */
 public function execute()
 {
     $curdir = getcwd();
     chdir($this->phpci->buildPath);
     $phpspec = $this->phpci->findBinary(array('phpspec', 'phpspec.php'));
     if (!$phpspec) {
         $this->phpci->logFailure(PHPCI\Helper\Lang::get('could_not_find', 'phpspec'));
         return false;
     }
     $success = $this->phpci->executeCommand($phpspec . ' --format=junit --no-code-generation run');
     $output = $this->phpci->getLastOutput();
     chdir($curdir);
     /*
      * process xml output
      *
      * <testsuites time=FLOAT tests=INT failures=INT errors=INT>
      *   <testsuite name=STRING time=FLOAT tests=INT failures=INT errors=INT skipped=INT>
      *     <testcase name=STRING time=FLOAT classname=STRING status=STRING/>
      *   </testsuite>
      * </testsuites
      */
     $xml = new \SimpleXMLElement($output);
     $attr = $xml->attributes();
     $data = array('time' => (double) $attr['time'], 'tests' => (int) $attr['tests'], 'failures' => (int) $attr['failures'], 'errors' => (int) $attr['errors'], 'suites' => array());
     /**
      * @var \SimpleXMLElement $group
      */
     foreach ($xml->xpath('testsuite') as $group) {
         $attr = $group->attributes();
         $suite = array('name' => (string) $attr['name'], 'time' => (double) $attr['time'], 'tests' => (int) $attr['tests'], 'failures' => (int) $attr['failures'], 'errors' => (int) $attr['errors'], 'skipped' => (int) $attr['skipped'], 'cases' => array());
         /**
          * @var \SimpleXMLElement $child
          */
         foreach ($group->xpath('testcase') as $child) {
             $attr = $child->attributes();
             $case = array('name' => (string) $attr['name'], 'classname' => (string) $attr['classname'], 'time' => (double) $attr['time'], 'status' => (string) $attr['status']);
             if ($case['status'] == 'failed') {
                 $error = array();
                 /*
                  * ok, sad, we had an error
                  *
                  * there should be one - foreach makes this easier
                  */
                 foreach ($child->xpath('failure') as $failure) {
                     $attr = $failure->attributes();
                     $error['type'] = (string) $attr['type'];
                     $error['message'] = (string) $attr['message'];
                 }
                 foreach ($child->xpath('system-err') as $system_err) {
                     $error['raw'] = (string) $system_err;
                 }
                 $case['error'] = $error;
             }
             $suite['cases'][] = $case;
         }
         $data['suites'][] = $suite;
     }
     $this->build->storeMeta('phpspec', $data);
     return $success;
 }
示例#6
0
 public function __construct(Builder $phpci, Build $build, array $options = array())
 {
     $this->phpci = $phpci;
     $this->build = $build;
     $buildSettings = $phpci->getConfig('build_settings');
     if (isset($buildSettings['redmine'])) {
         $redmine = $buildSettings['redmine'];
         $this->server = $redmine['server'];
         $this->apiKey = $redmine['api_key'];
     }
     if (isset($options['enabled'])) {
         $this->enabled = $options['enabled'];
     }
     if (isset($options['status'])) {
         $this->status = $options['status'];
     }
     if (isset($options['prev_status'])) {
         $this->prevStatus = $options['prev_status'];
     }
     if (isset($options['percent'])) {
         $this->percent = $options['percent'];
     }
     if (isset($options['lang'])) {
         $this->lang = $options['lang'];
     }
     if (isset($options['issue_regexp'])) {
         $this->issueRegexp = $options['issue_regexp'];
     }
     $parser = new YamlParser();
     $config = (array) $parser->parse(file_get_contents(__DIR__ . '/messages.yml'));
     $this->messages = $config[$this->lang];
 }
示例#7
0
文件: PhpLoc.php 项目: mrudtf/PHPCI
 /**
  * Runs PHP Copy/Paste Detector in a specified directory.
  */
 public function execute()
 {
     $ignore = '';
     if (count($this->phpci->ignore)) {
         $map = function ($item) {
             return ' --exclude ' . (substr($item, -1) == '/' ? substr($item, 0, -1) : $item);
         };
         $ignore = array_map($map, $this->phpci->ignore);
         $ignore = implode('', $ignore);
     }
     $phploc = $this->phpci->findBinary('phploc');
     if (!$phploc) {
         $this->phpci->logFailure(PHPCI\Helper\Lang::get('could_not_find', 'phploc'));
         return false;
     }
     $success = $this->phpci->executeCommand($phploc . ' %s "%s"', $ignore, $this->directory);
     $output = $this->phpci->getLastOutput();
     if (preg_match_all('/\\((LOC|CLOC|NCLOC|LLOC)\\)\\s+([0-9]+)/', $output, $matches)) {
         $data = array();
         foreach ($matches[1] as $k => $v) {
             $data[$v] = (int) $matches[2][$k];
         }
         $this->build->storeMeta('phploc', $data);
     }
     return $success;
 }
 /**
  * Setup the test environment.
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->builderMock = $this->getMockBuilder('PHPCI\\Builder')->getMock();
     $this->buildMock = $this->getMockBuilder('PHPCI\\Model\\Build')->getMock();
     $this->builderMock->method('log')->willReturn(null);
     $this->builderMock->method('logSuccess')->willReturn(null);
     $this->builderMock->method('logFailure')->willReturn(null);
     $this->buildMock->method('getBranch')->willReturn('master');
 }
示例#9
0
 /**
  * Run PHP CS Fixer.
  * @return bool
  */
 public function execute()
 {
     $curdir = getcwd();
     chdir($this->workingdir);
     $phpcsfixer = $this->phpci->findBinary('php-cs-fixer');
     $cmd = $phpcsfixer . ' fix . %s %s %s';
     $success = $this->phpci->executeCommand($cmd, $this->verbose, $this->diff, $this->level);
     chdir($curdir);
     return $success;
 }
示例#10
0
 /**
  * Handle post-clone tasks (switching branch, etc.)
  * @param Builder $builder
  * @param $cloneTo
  * @return bool
  */
 protected function postCloneSetup(Builder $builder, $cloneTo)
 {
     $success = true;
     $commit = $this->getCommitId();
     // Allow switching to a specific branch:
     if (!empty($commit) && $commit != 'Manual') {
         $cmd = 'cd "%s" && hg checkout %s';
         $success = $builder->executeCommand($cmd, $cloneTo, $this->getBranch());
     }
     return $success;
 }
示例#11
0
 protected function handleSymlink(Builder $builder, $reference, $buildPath)
 {
     if (is_link($buildPath) && is_file($buildPath)) {
         unlink($buildPath);
     }
     $builder->log(sprintf('Symlinking: %s to %s', $reference, $buildPath));
     if (!symlink($reference, $buildPath)) {
         $builder->logFailure('Failed to symlink.');
         return false;
     }
     return true;
 }
示例#12
0
 /**
  * Runs PHP Spec tests.
  */
 public function execute()
 {
     $curdir = getcwd();
     chdir($this->phpci->buildPath);
     $phpspec = $this->phpci->findBinary(array('phpspec', 'phpspec.php'));
     if (!$phpspec) {
         $this->phpci->logFailure('Could not find phpspec.');
         return false;
     }
     $success = $this->phpci->executeCommand($phpspec . ' --format=pretty --no-code-generation run');
     chdir($curdir);
     return $success;
 }
示例#13
0
 /**
  * Executes parallel lint
  */
 public function execute()
 {
     list($ignore) = $this->getFlags();
     $phplint = $this->phpci->findBinary('parallel-lint');
     $cmd = $phplint . ' %s "%s"';
     $success = $this->phpci->executeCommand($cmd, $ignore, $this->directory);
     $output = $this->phpci->getLastOutput();
     $matches = array();
     if (preg_match_all('/Parse error\\:/', $output, $matches)) {
         $this->build->storeMeta('phplint-errors', count($matches[0]));
     }
     return $success;
 }
示例#14
0
 /**
  * Connects to PgSQL and runs a specified set of queries.
  * @return boolean
  */
 public function execute()
 {
     try {
         $opts = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
         $pdo = new PDO('pgsql:host=' . $this->host, $this->user, $this->pass, $opts);
         foreach ($this->queries as $query) {
             $pdo->query($this->phpci->interpolate($query));
         }
     } catch (\Exception $ex) {
         $this->phpci->logFailure($ex->getMessage());
         return false;
     }
     return true;
 }
示例#15
0
文件: Irc.php 项目: ntoniazzi/PHPCI
 /**
  * Standard Constructor
  *
  * $options['directory'] Output Directory. Default: %BUILDPATH%
  * $options['filename']  Phar Filename. Default: build.phar
  * $options['regexp']    Regular Expression Filename Capture. Default: /\.php$/
  * $options['stub']      Stub Content. No Default Value
  *
  * @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->message = $options['message'];
     $buildSettings = $phpci->getConfig('build_settings');
     if (isset($buildSettings['irc'])) {
         $irc = $buildSettings['irc'];
         $this->server = $irc['server'];
         $this->port = $irc['port'];
         $this->room = $irc['room'];
         $this->nick = $irc['nick'];
     }
 }
示例#16
0
文件: Shell.php 项目: kukupigs/PHPCI
 /**
  * Runs the shell command.
  */
 public function execute()
 {
     if (!defined('ENABLE_SHELL_PLUGIN') || !ENABLE_SHELL_PLUGIN) {
         throw new \Exception('The shell plugin is not enabled.');
     }
     $success = true;
     foreach ($this->commands as $command) {
         $command = $this->phpci->interpolate($command);
         if (!$this->phpci->executeCommand($command)) {
             $success = false;
         }
     }
     return $success;
 }
示例#17
0
 /**
  * Run PHP CS Fixer.
  * @return bool
  */
 public function execute()
 {
     $curdir = getcwd();
     chdir($this->workingdir);
     $phpcsfixer = $this->phpci->findBinary('php-cs-fixer');
     if (!$phpcsfixer) {
         $this->phpci->logFailure(Lang::get('could_not_find', 'php-cs-fixer'));
         return false;
     }
     $cmd = $phpcsfixer . ' fix . %s %s %s';
     $success = $this->phpci->executeCommand($cmd, $this->verbose, $this->diff, $this->level);
     chdir($curdir);
     return $success;
 }
示例#18
0
文件: Sqlite.php 项目: mrudtf/PHPCI
 /**
  * Connects to SQLite and runs a specified set of queries.
  * @return boolean
  */
 public function execute()
 {
     try {
         $opts = array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION);
         $pdo = new PDO('sqlite:' . $this->path, $opts);
         foreach ($this->queries as $query) {
             $pdo->query($query);
         }
     } catch (\Exception $ex) {
         $this->phpci->logFailure($ex->getMessage());
         return false;
     }
     return true;
 }
示例#19
0
 /**
  * Wipes a directory's contents
  */
 public function execute()
 {
     $build = $this->phpci->buildPath;
     if ($this->directory == $build || empty($this->directory)) {
         return true;
     }
     if (is_dir($this->directory)) {
         $cmd = 'rm -Rf "%s"';
         if (IS_WIN) {
             $cmd = 'rmdir /S /Q "%s"';
         }
         return $this->phpci->executeCommand($cmd, $this->directory);
     }
     return true;
 }
示例#20
0
 /**
  * Run tests from a Codeception config file.
  * @param $configPath
  * @return bool|mixed
  * @throws \Exception
  */
 protected function runConfigFile($configPath)
 {
     $this->phpci->logExecOutput(false);
     $codecept = $this->phpci->findBinary('codecept');
     if (!$codecept) {
         $this->phpci->logFailure(Lang::get('could_not_find', 'codecept'));
         return false;
     }
     $cmd = 'cd "%s" && ' . $codecept . ' run -c "%s" --xml ' . $this->args;
     if (IS_WIN) {
         $cmd = 'cd /d "%s" && ' . $codecept . ' run -c "%s" --xml ' . $this->args;
     }
     $configPath = $this->phpci->buildPath . $configPath;
     $success = $this->phpci->executeCommand($cmd, $this->phpci->buildPath, $configPath);
     $this->phpci->log('Codeception XML path: ' . $this->phpci->buildPath . $this->path . 'report.xml', Loglevel::DEBUG);
     $xml = file_get_contents($this->phpci->buildPath . $this->path . 'report.xml', false);
     $parser = new Parser($this->phpci, $xml);
     $output = $parser->parse();
     $meta = array('tests' => $parser->getTotalTests(), 'timetaken' => $parser->getTotalTimeTaken(), 'failures' => $parser->getTotalFailures());
     $this->build->storeMeta('codeception-meta', $meta);
     $this->build->storeMeta('codeception-data', $output);
     $this->build->storeMeta('codeception-errors', $parser->getTotalFailures());
     $this->phpci->logExecOutput(true);
     return $success;
 }
示例#21
0
 /**
  * Run phptal lint against a specific file.
  * @param $path
  * @return bool
  */
 protected function lintFile($path)
 {
     $success = true;
     list($suffixes, $tales) = $this->getFlags();
     $lint = dirname(__FILE__) . '/../../vendor/phptal/phptal/tools/phptal_lint.php';
     $cmd = '/usr/bin/env php ' . $lint . ' %s %s "%s"';
     $this->phpci->executeCommand($cmd, $suffixes, $tales, $this->phpci->buildPath . $path);
     $output = $this->phpci->getLastOutput();
     if (preg_match('/Found (.+?) (error|warning)/i', $output, $matches)) {
         $rows = explode(PHP_EOL, $output);
         unset($rows[0]);
         unset($rows[1]);
         unset($rows[2]);
         unset($rows[3]);
         foreach ($rows as $row) {
             $name = basename($path);
             $row = str_replace('(use -i to include your custom modifier functions)', '', $row);
             $message = str_replace($name . ': ', '', $row);
             $parts = explode(' (line ', $message);
             $message = trim($parts[0]);
             $line = str_replace(')', '', $parts[1]);
             $this->failedPaths[] = array('file' => $path, 'line' => $line, 'type' => $matches[2], 'message' => $message);
         }
         $success = false;
     }
     return $success;
 }
示例#22
0
 /**
  * Set up the plugin, configure options, etc.
  * @param Builder $phpci
  * @param Build $build
  * @param array $options
  * @throws \Exception
  */
 public function __construct(Builder $phpci, Build $build, array $options = array())
 {
     $this->phpci = $phpci;
     $this->build = $build;
     $this->message = $options['message'];
     $this->userAgent = "PHPCI/1.0 (+http://www.phptesting.org/)";
     $this->cookie = "phpcicookie";
     $buildSettings = $phpci->getConfig('build_settings');
     if (isset($buildSettings['campfire'])) {
         $campfire = $buildSettings['campfire'];
         $this->url = $campfire['url'];
         $this->authToken = $campfire['authToken'];
         $this->roomId = $campfire['roomId'];
     } else {
         throw new \Exception(Lang::get('no_campfire_settings'));
     }
 }
示例#23
0
 /**
  * Run CasperJS tests.
  * @return bool
  */
 public function execute()
 {
     $this->phpci->logExecOutput(false);
     $casperJs = $this->phpci->findBinary('casperjs');
     if (!$casperJs) {
         $this->phpci->logFailure(Lang::get('could_not_find', 'casperjs'));
         return false;
     }
     $curdir = getcwd();
     chdir($this->phpci->buildPath);
     $cmd = $casperJs . " test {$this->tests_path} --xunit={$this->x_unit_file_path} {$this->arguments}";
     $success = $this->phpci->executeCommand($cmd);
     chdir($curdir);
     $xUnitString = file_get_contents($this->x_unit_file_path);
     try {
         $xUnitParser = new XUnitParser($xUnitString);
         $output = $xUnitParser->parse();
         $failures = $xUnitParser->getTotalFailures();
     } catch (\Exception $ex) {
         $this->phpci->logFailure($xUnitParser);
         throw $ex;
     }
     $this->build->storeMeta('casperJs-errors', $failures);
     $this->build->storeMeta('casperJs-data', $output);
     $this->phpci->logExecOutput(true);
     return $success;
 }
示例#24
0
 protected function runConfigFile($configPath)
 {
     if (is_array($configPath)) {
         return $this->recurseArg($configPath, array($this, "runConfigFile"));
     } else {
         $codecept = $this->phpci->findBinary('codecept');
         if (!$codecept) {
             $this->phpci->logFailure('Could not find codeception.');
             return false;
         }
         $cmd = 'cd "%s" && ' . $codecept . ' run -c "%s" ' . $this->args;
         if (IS_WIN) {
             $cmd = 'cd /d "%s" && ' . $codecept . ' run -c "%s" ' . $this->args;
         }
         $configPath = $this->phpci->buildPath . $configPath;
         $success = $this->phpci->executeCommand($cmd, $this->phpci->buildPath, $configPath);
         return $success;
     }
 }
示例#25
0
 /**
  * Execute JSHint.
  * @param $binaryPath
  */
 protected function executeJsHint($binaryPath)
 {
     $cmd = $binaryPath . ' %s --reporter checkstyle';
     $path = $this->getTargetPath();
     // Disable exec output logging, as we don't want the XML report in the log:
     $this->phpci->logExecOutput(false);
     // Run JSHint:
     $this->phpci->executeCommand($cmd, $path);
     // Re-enable exec output logging:
     $this->phpci->logExecOutput(true);
 }
 /**
  * Runs the copy command.
  *
  * @return bool
  */
 public function execute()
 {
     $destinationFilename = $this->phpci->buildPath . '/' . $this->envFilename;
     $this->phpci->log(sprintf('Copy external environment file %s for the %s branch to build directory', $this->envFilepath, $this->branch));
     if (!copy($this->envFilepath, $destinationFilename)) {
         $this->phpci->logFailure('Copy error environment file to build directory!');
         return false;
     }
     $this->phpci->logSuccess('External environment file successful copied.');
     return true;
 }
示例#27
0
 /**
  * Runs the plugin
  */
 public function execute()
 {
     $success = true;
     $this->phpci->logExecOutput(false);
     $errorCount = $this->getErrorList();
     $this->phpci->log("Found {$errorCount} instances of " . implode(', ', $this->searches));
     $this->build->storeMeta('technical_debt-warnings', $errorCount);
     if ($this->allowed_errors != -1 && $errorCount > $this->allowed_errors) {
         $success = false;
     }
     return $success;
 }
示例#28
0
 /**
  * Send a notification mail.
  */
 public function execute()
 {
     $addresses = $this->getEmailAddresses();
     // Without some email addresses in the yml file then we
     // can't do anything.
     if (count($addresses) == 0) {
         return false;
     }
     $buildStatus = $this->build->isSuccessful() ? "Passing Build" : "Failing Build";
     $projectName = $this->build->getProject()->getTitle();
     $mailTemplate = $this->build->isSuccessful() ? 'Email/success' : 'Email/failed';
     $view = new View($mailTemplate);
     $view->build = $this->build;
     $view->project = $this->build->getProject();
     $body = $view->render();
     $sendFailures = $this->sendSeparateEmails($addresses, sprintf("PHPCI - %s - %s", $projectName, $buildStatus), $body);
     // This is a success if we've not failed to send anything.
     $this->phpci->log(sprintf("%d emails sent", count($addresses) - $sendFailures));
     $this->phpci->log(sprintf("%d emails failed to send", $sendFailures));
     return $sendFailures === 0;
 }
示例#29
0
 /**
  * Runs PHP Mess Detector in a specified directory.
  */
 public function execute()
 {
     // Check that the binary exists:
     $checker = $this->phpci->findBinary('phpdoccheck');
     if (!$checker) {
         $this->phpci->logFailure('Could not find phpdoccheck.');
         return false;
     }
     // Build ignore string:
     $ignore = '';
     if (count($this->ignore)) {
         $ignore = ' --exclude="' . implode(',', $this->ignore) . '"';
     }
     // Are we skipping any checks?
     $add = '';
     if ($this->skipClasses) {
         $add .= ' --skip-classes';
     }
     if ($this->skipMethods) {
         $add .= ' --skip-methods';
     }
     // Build command string:
     $path = $this->phpci->buildPath . $this->path;
     $cmd = $checker . ' --json --directory="%s"%s%s';
     // Disable exec output logging, as we don't want the XML report in the log:
     $this->phpci->logExecOutput(false);
     // Run checker:
     $this->phpci->executeCommand($cmd, $path, $ignore, $add);
     // Re-enable exec output logging:
     $this->phpci->logExecOutput(true);
     $output = json_decode($this->phpci->getLastOutput());
     $errors = count($output);
     $success = true;
     $this->build->storeMeta('phpdoccheck-warnings', $errors);
     $this->build->storeMeta('phpdoccheck-data', $output);
     if ($this->allowed_warnings != -1 && $errors > $this->allowed_warnings) {
         $success = false;
     }
     return $success;
 }
示例#30
0
 /**
  * Runs PHP Copy/Paste Detector in a specified directory.
  */
 public function execute()
 {
     $ignore = '';
     if (count($this->phpci->ignore)) {
         $map = function ($item) {
             return ' --exclude ' . rtrim($item, DIRECTORY_SEPARATOR);
         };
         $ignore = array_map($map, $this->phpci->ignore);
         $ignore = implode('', $ignore);
     }
     $phploc = $this->phpci->findBinary('phploc');
     $success = $this->phpci->executeCommand($phploc . ' %s "%s"', $ignore, $this->directory);
     $output = $this->phpci->getLastOutput();
     if (preg_match_all('/\\((LOC|CLOC|NCLOC|LLOC)\\)\\s+([0-9]+)/', $output, $matches)) {
         $data = array();
         foreach ($matches[1] as $k => $v) {
             $data[$v] = (int) $matches[2][$k];
         }
         $this->build->storeMeta('phploc', $data);
     }
     return $success;
 }