private function _sendPearMail($from, $to, $subject, $message) { require_once 'Xinc/Ini.php'; try { $smtpSettings = Xinc_Ini::getInstance()->get('email_smtp'); } catch (Exception $e) { $smtpSettings = null; } if ($smtpSettings != null) { $mailer = Mail::factory('smtp', $smtpSettings); } else { $mailer = Mail::factory('mail'); } $recipients = split(',', $to); $headers = array(); if (isset($smtpSettings['localhost'])) { $from = str_replace('@localhost', '@' . $smtpSettings['localhost'], $from); } $headers['From'] = $from; $headers['Subject'] = $subject; $res = $mailer->send($recipients, $headers, $message); if ($res === true) { return $res; } else { return false; } }
public function __construct() { $svnPath = Xinc_Ini::getInstance()->get('path', 'svn'); if (empty($svnPath)) { $svnPath = 'svn'; } $this->_svnPath = $svnPath; }
/** * Constructor */ public function __construct() { try { $this->strPath = Xinc_Ini::getInstance()->get('path', 'git'); } catch (Exception $e) { $this->strPath = 'git'; } }
public function __construct(Xinc_Plugin_Interface $plugin) { parent::__construct($plugin); try { $this->tmpDir = Xinc_Ini::getInstance()->get('tmp_dir', 'xinc'); } catch (Exception $e) { $this->tmpDir = '/tmp/'; } }
<?php require_once 'Xinc/Ini.php'; require_once 'Xinc/Gui/Handler.php'; /* * get environment variables or read config.xml */ $handler = new Xinc_Gui_Handler(Xinc_Ini::getInstance()->get('etc', 'xinc') . DIRECTORY_SEPARATOR . 'system.xml', Xinc_Ini::getInstance()->get('status_dir', 'xinc')); $handler->view();
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; }
/** * calling phing * * @param Xinc_Build_Interface $build * @param string $buildfile * @param string $target * @param string $extraParams * @param string $workingDir * * @return boolean */ public function build(Xinc_Build_Interface $build, $buildfile, $target, $extraParams = null, $workingDir = null) { //$phing = new Phing(); $logLevel = Xinc_Logger::getInstance()->getLogLevel(); $arguments = array(); switch ($logLevel) { case Xinc_Logger::LOG_LEVEL_VERBOSE: $arguments[] = '-verbose'; break; } $oldPwd = getcwd(); /** * set workingdir if not set from task, * use project dir */ if ($workingDir == null) { $workingDir = Xinc::getInstance()->getProjectDir() . DIRECTORY_SEPARATOR . $build->getProject()->getName(); } if (is_dir($workingDir)) { Xinc_Logger::getInstance()->debug('Switching to directory: ' . $workingDir); chdir($workingDir); } $logFile = getcwd() . DIRECTORY_SEPARATOR . md5($build->getProject()->getName() . time()) . '.log'; if (file_exists($logFile)) { unlink($logFile); } $arguments[] = '-logger'; //$arguments[] = 'phing.listener.DefaultLogger'; $arguments[] = 'phing.listener.NoBannerLogger'; $arguments[] = '-logfile'; $arguments[] = $logFile; $arguments[] = '-buildfile'; $arguments[] = $buildfile; if ($target != null) { $arguments[] = $target; } $arguments[] = '-Dxinc.buildlabel=' . $this->_encodeParam($build->getLabel()); $arguments[] = '-Dprojectname=' . $this->_encodeParam($build->getProject()->getName()); $arguments[] = '-Dcctimestamp=' . $this->_encodeParam($build->getBuildTime()); foreach ($build->getProperties()->getAllProperties() as $name => $value) { $arguments[] = '-Dxinc.' . $this->_encodeParam($name) . '=' . $this->_encodeParam($value); } try { $phingPath = Xinc_Ini::getInstance()->get('path', 'phing'); } catch (Exception $e) { $phingPath = null; } if (empty($phingPath)) { if (DIRECTORY_SEPARATOR != '/') { /** * windows has the phing command inside the bin_dir directory */ $phingPath = PEAR_Config::singleton()->get('bin_dir') . DIRECTORY_SEPARATOR . 'phing'; } else { $phingPath = 'phing'; } } if (DIRECTORY_SEPARATOR == '/') { $redirect = "2>&1"; } else { $redirect = ""; } $command = $phingPath . ' ' . implode(' ', $arguments) . ' ' . $extraParams . ' ' . $redirect; exec($command, $output, $returnValue); chdir($oldPwd); $buildSuccess = false; if (file_exists($logFile)) { $fh = fopen($logFile, 'r'); if (is_resource($fh)) { while ($line = fgets($fh)) { Xinc_Logger::getInstance()->info($line); if (strstr($line, "BUILD FINISHED")) { $buildSuccess = true; } } fclose($fh); } unlink($logFile); } if (count($output) > 0) { Xinc_Logger::getInstance()->error('Errors on command line:'); foreach ($output as $line) { Xinc_Logger::getInstance()->error($line); } } switch ($returnValue) { case 0: case 1: if ($buildSuccess) { return true; } else { $build->error('Phing command ' . $command . ' exited with status: ' . $returnValue); $build->setStatus(Xinc_Build_Interface::FAILED); return false; } break; case -1: case -2: $build->error('Phing build script: ' . $command . ' exited with status: ' . $returnValue); $build->setStatus(Xinc_Build_Interface::FAILED); return false; break; } return false; }
/** * returns the status dir * * @return string */ private static function _getStatusDir() { $statusDir = null; $isGuiMode = false; $isXincMode = false; if (class_exists('Xinc_Gui_Handler')) { $handler = Xinc_Gui_Handler::getInstance(); $isGuiMode = $handler instanceof Xinc_Gui_Handler; } if (class_exists('Xinc')) { $xinc = Xinc::getInstance(); $isXincMode = $xinc instanceof Xinc; } if ($isGuiMode) { // we are in gui mode $statusDir = Xinc_Gui_Handler::getInstance()->getStatusDir(); } else { if ($isXincMode) { $statusDir = Xinc::getInstance()->getStatusDir(); } else { try { $statusDir = Xinc_Ini::getInstance()->get('status_dir', 'xinc'); } catch (Exception $e) { $statusDir = null; } } } return $statusDir; }