Ejemplo n.º 1
0
 public function getContent(Xinc_Build_Interface $build)
 {
     $deliverableLinkTemplateFile = Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'extension' . DIRECTORY_SEPARATOR . 'documentation-link.phtml');
     $deliverableLinkTemplate = file_get_contents($deliverableLinkTemplateFile);
     $getDeliverableUrl = './api/documentation/get/file/' . $build->getProject()->getName() . '/' . $build->getBuildTime() . '/';
     $statusDir = Xinc_Gui_Handler::getInstance()->getStatusDir();
     $subDir = $build->getStatusSubDir();
     $docDir = $statusDir . DIRECTORY_SEPARATOR . $subDir . DIRECTORY_SEPARATOR . Xinc_Plugin_Repos_Documentation::DOCUMENTATION_DIR;
     $deliverableLinks = array();
     $docs = $build->getInternalProperties()->get('documentation');
     if (!is_array($docs)) {
         return false;
     }
     foreach ($docs as $alias => $array) {
         $publicName = $alias;
         $dirName = dirname($array['file']);
         $indexFile = preg_replace('/\\/+/', '/', $array['index']);
         $myDocDir = $docDir . DIRECTORY_SEPARATOR . $publicName;
         $myDocDir = preg_replace('/\\/+/', '/', $myDocDir);
         $indexFile = str_replace($myDocDir, '', $indexFile);
         $link = $getDeliverableUrl . $publicName . '/' . $indexFile;
         $link = preg_replace('/\\/+/', '/', $link);
         $deliverableLinks[] = call_user_func_array('sprintf', array($deliverableLinkTemplate, $link, $publicName));
     }
     return implode(', ', $deliverableLinks);
 }
Ejemplo n.º 2
0
 public function getContent(Xinc_Build_Interface $build)
 {
     $deliverableLinkTemplateFile = Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'extension' . DIRECTORY_SEPARATOR . 'deliverable-link.phtml');
     $deliverableLinkTemplate = file_get_contents($deliverableLinkTemplateFile);
     $getDeliverableUrl = './api/deliverable/get/download/' . $build->getProject()->getName() . '/' . $build->getBuildTime() . '/';
     $deliverableLinks = array();
     $deliverables = $build->getInternalProperties()->get('deliverables');
     if (!isset($deliverables['deliverables'])) {
         return false;
     }
     foreach ($deliverables['deliverables'] as $fileName => $fileLocation) {
         $publicName = $fileName;
         foreach ($deliverables['aliases'] as $alias => $realName) {
             if ($realName == $publicName) {
                 $publicName = $alias;
                 break;
             }
         }
         $link = $getDeliverableUrl . $publicName;
         $deliverableLinks[] = call_user_func_array('sprintf', array($deliverableLinkTemplate, $link, $publicName));
     }
     return implode(', ', $deliverableLinks);
 }
 /**
  * Copies a file into a special test results directory for the build and
  * parse the xml file to generate statistics
  *
  * @param Xinc_Build_Interface $build      The actuall build.
  * @param string               $sourceFile The xml file to read out.
  *
  * @return boolean True if registering was ok, false if it failed.
  */
 public function registerResults(Xinc_Build_Interface $build, $sourceFile)
 {
     $statusDir = Xinc::getInstance()->getStatusDir();
     $projectDir = Xinc::getInstance()->getProjectDir();
     $subDir = $build->getStatusSubDir();
     $fullDir = $statusDir . DIRECTORY_SEPARATOR . $subDir . DIRECTORY_SEPARATOR . self::TESTRESULTS_DIR;
     $targetFile = $fullDir . DIRECTORY_SEPARATOR . basename($sourceFile);
     /**
      * Verify that the source is in the projectdir
      */
     $relativePath = str_replace($projectDir, '', $sourceFile);
     if ($relativePath == $sourceFile) {
         /**
          * the filename was not within the project path,
          * we need to prevent this file from being copied.
          * 
          * Future: run Xinc in a chroot environment per project
          */
         $build->error('Registering test results: ' . $sourceFile . '->' . $targetFile . ' failed.');
         $build->error('-- ' . $sourceFile . ' is not within project dir. Security Problem.');
         return false;
     }
     if (!file_exists($fullDir)) {
         mkdir($fullDir, 0755, true);
     }
     if (is_dir($sourceFile)) {
         if (DIRECTORY_SEPARATOR == '\\') {
             exec('xcopy /E /Y /I ' . $sourceFile . ' ' . $targetFile, $out, $res);
             //chmod($targetFile, 0755);
         } else {
             exec('cp -Rf ' . $sourceFile . ' ' . $targetFile, $out, $res);
         }
         if ($res == 0) {
             $status = 'OK';
         } else {
             $status = 'FAILURE';
         }
     } elseif (is_file($sourceFile)) {
         $res = copy($sourceFile, $targetFile);
         if ($res) {
             chmod($targetFile, 0755);
             $status = 'OK';
             /**
              * register statistics
              */
             $build->getInternalProperties()->set('phpunit.file', $targetFile);
             $this->generateStats($build, $targetFile);
         } else {
             $status = 'FAILURE';
         }
     } else {
         $build->error('The phpunit file ' . $sourceFile . ' couldn\'t be read.');
         return false;
     }
     $build->info('Registering test results: ' . $sourceFile . '->' . $targetFile . ', result: ' . $status);
     return $res;
 }
Ejemplo n.º 4
0
 public function getTestResults(Xinc_Build_Interface $build)
 {
     require_once 'PEAR/Config.php';
     $statusDir = Xinc_Gui_Handler::getInstance()->getStatusDir();
     $projectName = $build->getProject()->getName();
     $buildTimestamp = $build->getBuildTime();
     $buildLabel = $build->getLabel();
     $templateFile = Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'extension' . DIRECTORY_SEPARATOR . 'phpunit-summary.phtml');
     $template = file_get_contents($templateFile);
     $url = '/phpunit/results/?project=' . $projectName . '&buildtime=' . $buildTimestamp . '&f=results.html';
     $sourceFile = $build->getInternalProperties()->get('phpunit.file');
     if ($sourceFile != null && file_exists($sourceFile) && class_exists('XSLTProcessor')) {
         $xslFile = Xinc_Data_Repository::getInstance()->getPlugins('resources' . DIRECTORY_SEPARATOR . 'phpunit' . DIRECTORY_SEPARATOR . 'summary.xsl');
         try {
             $outputFileName = Xinc_Ini::getInstance()->get('tmp_dir', 'xinc') . DIRECTORY_SEPARATOR . 'phpunit_summary_' . $projectName . '_' . $buildTimestamp;
         } catch (Exception $e) {
             Xinc_Logger::getInstance()->error('Cannot get xinc.ini configuration');
             $outputFileName = 'phpunit_summary_' . $projectName . '_' . $buildTimestamp;
         }
         if (file_exists($outputFileName)) {
             $summary = file_get_contents($outputFileName);
         } else {
             $summary = $this->_transformResults($sourceFile, $xslFile, $outputFileName);
         }
         //$click = 'openMenuTab(\'phpunit-'.$projectName.'-'.$buildTimestamp.'\',\'PHPUnit - '.$projectName.'\',\''.$url.'\',null,false,false,\'auto\');';
         $detailsLink = '<a href="' . $url . '">Details</a>';
         $content = str_replace(array('{detailsLink}', '{summary}'), array($detailsLink, $summary), $template);
     } else {
         $content = false;
     }
     return $content;
 }