public function testOneBuildToBuild() { $build = new Xinc_Build(new Xinc_Engine_Sunrise(), new Xinc_Project()); $queue = new Xinc_Build_Queue(); $scheduler = new Xinc_Build_Scheduler_Default(); $build->setScheduler($scheduler); $queue->addBuild($build); $nextBuildTime = $queue->getNextBuildTime(); $this->assertTrue($nextBuildTime != null, 'We should have a default builttime'); $nextBuild = $queue->getNextBuild(); $this->assertEquals($build, $nextBuild, 'The Builds should be equal'); }
public function buildDataSet(Xinc_Project $project, array $buildHistoryArr = array(), $previousData = array()) { if (count($previousData) > 0) { $data = $previousData; } else { $data = array('Number of Tests' => array(), 'Passed tests' => array(), 'Failed tests' => array()); } $builds = array(); foreach ($buildHistoryArr as $buildTimestamp => $buildFileName) { try { $buildObject = Xinc_Build::unserialize($project, $buildTimestamp, Xinc_Gui_Handler::getInstance()->getStatusDir()); $buildNo = $buildObject->getNumber(); if (isset($builds[$buildNo])) { $builds[$buildNo]++; $buildNo .= '.f' . $builds[$buildNo]; } else { $builds[$buildNo] = 0; } if ($buildObject->getStatistics()->get('phpunit.numberOfTests') > 0) { $data['Number of Tests'][$buildNo] = $buildObject->getStatistics()->get('phpunit.numberOfTests'); $data['Failed tests'][$buildNo] = $buildObject->getStatistics()->get('phpunit.numberOfFailures'); $data['Passed tests'][$buildNo] = $buildObject->getStatistics()->get('phpunit.numberOfTests') - $buildObject->getStatistics()->get('phpunit.numberOfFailures'); } else { $data['Number of Tests'][$buildNo] = 0; $data['Failed tests'][$buildNo] = 0; $data['Passed tests'][$buildNo] = 0; } unset($buildObject); } catch (Exception $e) { // TODO: Handle } } return $data; }
public function buildDataSet(Xinc_Project $project, array $buildHistoryArr = array(), $previousData = array()) { if (count($previousData) > 0) { $data = $previousData; } else { $data = array('Files' => array(), 'Warnings' => array(), 'Errors' => array()); } $builds = array(); foreach ($buildHistoryArr as $buildTimestamp => $buildFileName) { try { $buildObject = Xinc_Build::unserialize($project, $buildTimestamp, Xinc_Gui_Handler::getInstance()->getStatusDir()); $numberOfFiles = $buildObject->getStatistics()->get('checkstyle.numberOfFiles'); if (null === $numberOfFiles) { continue; } $buildNo = $buildObject->getNumber(); if (isset($builds[$buildNo])) { $builds[$buildNo]++; $buildNo .= '.f' . $builds[$buildNo]; } else { $builds[$buildNo] = 0; } $data['Files'][$buildNo] = $numberOfFiles; $data['Warnings'][$buildNo] = $buildObject->getStatistics()->get('checkstyle.numberOfWarnings'); $data['Errors'][$buildNo] = $buildObject->getStatistics()->get('checkstyle.numberOfErrors'); $prevBuildNo = $buildNo; unset($buildObject); } catch (Exception $e) { // TODO: Handle } } return $data; }
/** * Parses the projects xml * loads all the tasks * assigns them to the builds * * @param Xinc\Core\Project\Iterator $projects * * @return array the builds */ public function parseProjectOld($project) { $builds = array(); // $this->setters = Xinc_Plugin_Repository::getInstance() // ->getTasksForSlot(Xinc_Plugin_Slot::PROJECT_SET_VALUES); $build = null; /** * trying to recover the last build information */ try { $build = \Xinc\Core\Build::unserialize($project); $build->setBuildTime(null); $build->resetConfigDirective(); } catch (Xinc_Build_Exception_NotFound $e) { Xinc_Logger::getInstance()->info('No status data found for ' . $project->getName()); } catch (Exception $e) { Xinc_Logger::getInstance()->error('Could not unserialize old status of ' . $project->getName()); } $projectXml = $project->getConfig(); if (!$build instanceof Xinc_Build_Interface) { $build = new Xinc_Build($this->engine, $project); } $build->getProperties()->set('project.name', $project->getName()); $build->getProperties()->set('build.number', $build->getNumber()); $build->getProperties()->set('build.label', $build->getLabel()); $builtinProps = Xinc::getInstance()->getBuiltinProperties(); foreach ($builtinProps as $prop => $value) { $build->getProperties()->set($prop, $value); } $taskRegistry = new Xinc_Build_Tasks_Registry(); $this->_parseTasks($build, $projectXml, $taskRegistry); $build->setTaskRegistry($taskRegistry); $build->process(Xinc_Plugin_Slot::PROJECT_INIT); if (!$build->haveScheduler()) { // set default scheduler $scheduler = new Xinc_Build_Scheduler_Default(); $build->addScheduler($scheduler); } $labeler = $build->getLabeler(); if ($labeler == null) { // set default scheduler $labeler = new Xinc_Build_Labeler_Default(); $build->setLabeler($labeler); } $builds[] = $build; return $builds; }
/** * Gets a build defined by its project name and buildTime * * @param string $projectName * @param integer $buildTime * @throws Xinc_Build_Exception_Unserialization * @throws Xinc_Build_Exception_NotFound * @return Xinc_Build_Interface */ public static function getBuild(Xinc_Project $project, $buildTime) { $statusDir = null; if (class_exists('Xinc_Gui_Handler')) { $statusDir = Xinc_Gui_Handler::getInstance()->getStatusDir(); } else { if (class_exists('Xinc')) { $statusDir = Xinc::getInstance()->getStatusDir(); } } return Xinc_Build::unserialize($project, $buildTime, $statusDir); }
public function handleEvent($eventId) { $query = $_SERVER['REQUEST_URI']; $projectName = isset($_REQUEST['project']) ? $_REQUEST['project'] : null; $buildTime = isset($_REQUEST['buildtime']) ? $_REQUEST['buildtime'] : null; if (empty($projectName) || empty($buildTime)) { die('Could not find phpunit test results'); } $project = new Xinc_Project(); $project->setName($projectName); try { $build = Xinc_Build::unserialize($project, $buildTime, Xinc_Gui_Handler::getInstance()->getStatusDir()); $buildLabel = $build->getLabel(); $timezone = $build->getConfigDirective('timezone'); if ($timezone !== null) { Xinc_Timezone::set($timezone); } else { $xincTimezone = Xinc_Gui_Handler::getInstance()->getConfigDirective('timezone'); if ($xincTimezone !== null) { Xinc_Timezone::set($xincTimezone); } else { Xinc_Timezone::set(Xinc_Gui_Handler::getInstance()->getSystemTimezone()); } } $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 . 'details.xsl'); try { $outputFileName = Xinc_Ini::getInstance()->get('tmp_dir', 'xinc') . DIRECTORY_SEPARATOR . 'phpunit_details_' . $projectName . '_' . $buildTime; } catch (Exception $e) { Xinc_Logger::getInstance()->error('Cannot get xinc.ini configuration'); $outputFileName = 'phpunit_details_' . $projectName . '_' . $buildTime; } if (file_exists($outputFileName)) { $details = file_get_contents($outputFileName); } else { $details = $this->_transformResults($sourceFile, $xslFile, $outputFileName); } //$click = 'openMenuTab(\'phpunit-'.$projectName.'-'.$buildTimestamp.'\',\'PHPUnit - '.$projectName.'\',\''.$url.'\',null,false,false,\'auto\');'; $title = 'PHPUnit Test Results'; $buildTimeString = date('Y-m-d H:i:s', $build->getBuildTime()) . '-' . Xinc_Timezone::get(); $content = str_replace(array('{title}', '{details}', '{projectName}', '{buildLabel}', '{buildTime}'), array($title, $details, $projectName, $buildLabel, $buildTimeString), $details); } else { $content = false; } Xinc_Timezone::reset(); echo $content; } catch (Exception $e) { echo "Could not find phpunit test results"; } }
public function handleEvent($eventId) { $query = urldecode($_SERVER['REQUEST_URI']); preg_match("/\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*)/", $query, $matches); if (count($matches) != 6) { echo "Could not find artifact"; return; } $projectName = $matches[3]; $buildTime = $matches[4]; $file = $matches[5]; $project = new Xinc_Project(); $project->setName($projectName); try { $build = Xinc_Build::unserialize($project, $buildTime, Xinc_Gui_Handler::getInstance()->getStatusDir()); $statusDir = Xinc_Build_History::getBuildDir($project, $buildTime); $statusDir .= DIRECTORY_SEPARATOR . Xinc_Plugin_Repos_Artifacts::ARTIFACTS_DIR . DIRECTORY_SEPARATOR; /** * Replace multiple / slashes with just one */ $fileName = $statusDir . $file; $fileName = preg_replace('/\\' . DIRECTORY_SEPARATOR . '+/', DIRECTORY_SEPARATOR, $fileName); $realfile = realpath($fileName); if ($realfile != $fileName) { echo "Could not find artifact"; } else { if (file_exists($fileName)) { $contentType = $this->mime_content_type2($fileName); if (!empty($contentType)) { header("Content-Type: " . $contentType); } readfile($fileName); } else { echo "Could not find artifact"; } } } catch (Exception $e) { echo "Could not find any artifacts"; } }
public function buildDataSet(Xinc_Project $project, array $buildHistoryArr = array(), $previousData = array()) { if (count($previousData) > 0) { $data = $previousData; } else { $data = array('Build Status' => array('Successful Builds' => 0, 'Failed Builds' => 0)); } foreach ($buildHistoryArr as $buildTimestamp => $buildFileName) { try { $buildObject = Xinc_Build::unserialize($project, $buildTimestamp, Xinc_Gui_Handler::getInstance()->getStatusDir()); if ($buildObject->getStatus() == Xinc_Build_Interface::PASSED) { $data['Build Status']['Successful Builds']++; } else { $data['Build Status']['Failed Builds']++; } unset($buildObject); } catch (Exception $e) { // TODO: Handle } } return $data; }
public function buildDataSet(Xinc_Project $project, array $buildHistoryArr = array(), $previousData = array()) { if (count($previousData) > 0) { $data = $previousData; } else { $data = array('Successful Builds' => array(), 'Failed Builds' => array()); } $builds = array(); foreach ($buildHistoryArr as $buildTimestamp => $buildFileName) { try { $buildObject = Xinc_Build::unserialize($project, $buildTimestamp, Xinc_Gui_Handler::getInstance()->getStatusDir()); $duration = $buildObject->getStatistics()->get('build.duration'); $buildNo = $buildObject->getNumber(); if (!is_numeric($duration)) { $duration = 0; } if (isset($builds[$buildNo])) { $builds[$buildNo]++; $buildNo .= '.f' . $builds[$buildNo]; } else { $builds[$buildNo] = 0; } if ($buildObject->getStatus() == Xinc_Build_Interface::PASSED) { $data['Successful Builds'][$buildNo] = $duration; $data['Failed Builds'][$buildNo] = 0; } else { $data['Failed Builds'][$buildNo] = $duration; $data['Successful Builds'][$buildNo] = 0; } $prevBuildNo = $buildNo; unset($buildObject); } catch (Exception $e) { // TODO: Handle } } return $data; }
public function testLogging() { $project = new Xinc_Project(); $project->setName('test'); $build = new Xinc_Build(new Xinc_Engine_Sunrise(), $project); $name = 'test ' . rand(21213, 123213); $project->setName($name); $message = 'info ' . rand(3123123, 123123213); $build->info($message); $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message'); $message = 'debug ' . rand(3123123, 123123213); $build->debug($message); $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message'); $message = 'warn ' . rand(3123123, 123123213); $build->warn($message); $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message'); $message = 'error ' . rand(3123123, 123123213); $build->error($message); $this->assertTrue(strpos(Xinc_StreamLogger::getLastLogMessage(), $message) !== false, 'Last message should contain message'); Xinc_Logger::getInstance()->setLogLevel(Xinc_Logger::LOG_LEVEL_VERBOSE); $message = 'verbose ' . rand(3123123, 123123213); ob_start(); $build->verbose($message); $contents = ob_get_clean(); $lastMsg = Xinc_StreamLogger::getLastLogMessage(); Xinc_Logger::getInstance()->setLogLevel(Xinc_Logger::LOG_LEVEL_DEBUG); $this->assertTrue(strpos($lastMsg, $message) !== false, 'Last message should contain message'); //$this->assertEquals($lastMsg, $contents, // 'Last message should contain message'); }
public function handleEvent($eventId) { $this->projectName = $_GET['project']; if (isset($_GET['timestamp'])) { $this->buildTimeStamp = $_GET['timestamp']; } $this->project = new Xinc_Project(); $this->project->setName($this->projectName); switch ($eventId) { case Xinc_Gui_Event::PAGE_LOAD: $handler = Xinc_Gui_Handler::getInstance(); $statusDir = $handler->getStatusDir(); if ($this->buildTimeStamp != null) { $fullStatusDir = Xinc_Build_History::getBuildDir($this->project, $this->buildTimeStamp); } else { $fullStatusDir = Xinc_Build_History::getLastBuildDir($this->project); $this->buildTimeStamp = Xinc_Build_History::getLastBuildTime($this->project); } //$statusFile = $fullStatusDir . DIRECTORY_SEPARATOR . 'build.ser'; $this->build = Xinc_Build::unserialize($this->project, $this->buildTimeStamp, Xinc_Gui_Handler::getInstance()->getStatusDir()); $timezone = $this->build->getConfigDirective('timezone'); if ($timezone !== null) { Xinc_Timezone::set($timezone); } $detailDir = $fullStatusDir; /** * get History Builds */ //$this->historyBuilds = $this->getHistoryBuilds($statusDir); /** * Generate the build selector on the right */ $this->_generateBuildsView(); /** * Overview info tab */ $this->_generateSummaryView(); /** * Generate the tab for the log messages */ $this->_generateLogView(); /** * Generate the external tabs that were registered through a hook */ $this->_generateExternalExtensions(); include Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'projectDetail.phtml'); break; default: break; } /** * restore to system timezone */ $xincTimezone = Xinc_Gui_Handler::getInstance()->getConfigDirective('timezone'); if ($xincTimezone !== null) { Xinc_Timezone::set($xincTimezone); } else { Xinc_Timezone::reset(); } }
public function configure(Xinc_Build $build) { $build->setConfigDirective($this->_name, $this->_value); }
/** * Get history of all the builds for a project * * @param string $projectName * @param integer $start * @param integer $limit * * @return stdClass */ private function _getHistoryBuilds($projectName, $start, $limit = null) { $statusDir = Xinc_Gui_Handler::getInstance()->getStatusDir(); $historyFile = $statusDir . DIRECTORY_SEPARATOR . $projectName . '.history'; $project = new Xinc_Project(); $project->setName($projectName); $buildHistoryArr = unserialize(file_get_contents($historyFile)); $totalCount = count($buildHistoryArr); if ($limit == null) { $limit = $totalCount; } $buildHistoryArr = array_slice($buildHistoryArr, $start, $limit, true); $builds = array(); foreach ($buildHistoryArr as $buildTimestamp => $buildFileName) { try { $buildObject = Xinc_Build::unserialize($project, $buildTimestamp, Xinc_Gui_Handler::getInstance()->getStatusDir()); $builds[] = array('buildtime' => $buildObject->getBuildTime(), 'label' => $buildObject->getLabel()); } catch (Exception $e) { // TODO: Handle } } $builds = array_reverse($builds); $object = new stdClass(); $object->totalcount = $totalCount; $object->builds = $builds; //return new Xinc_Build_Iterator($builds); return $object; }
/** * Get a list of all builds of a project * * @param string $projectName * @param integer $start * @param integer $limit * * @return stdClass */ private function _getHistoryBuildsOld($projectName, $start, $limit = null) { $statusDir = Xinc_Gui_Handler::getInstance()->getStatusDir(); $historyFile = $statusDir . DIRECTORY_SEPARATOR . $projectName . '.history'; $project = new Xinc_Project(); $project->setName($projectName); $buildHistoryArr = unserialize(file_get_contents($historyFile)); $totalCount = count($buildHistoryArr); if ($limit == null) { $limit = $totalCount; } /** * turn it upside down so the latest builds appear first */ $buildHistoryArr = array_reverse($buildHistoryArr, true); $buildHistoryArr = array_slice($buildHistoryArr, $start, $limit, true); $builds = array(); foreach ($buildHistoryArr as $buildTimestamp => $buildFileName) { try { $buildObject = Xinc_Build::unserialize($project, $buildTimestamp, Xinc_Gui_Handler::getInstance()->getStatusDir()); $timezone = $buildObject->getConfigDirective('timezone'); if ($timezone !== null) { Xinc_Timezone::set($timezone); } $builds[] = array('buildtime' => date('Y-m-d H:i:s', $buildObject->getBuildTime()), 'timezone' => Xinc_Timezone::get(), 'buildtimeRaw' => $buildObject->getBuildTime(), 'label' => $buildObject->getLabel(), 'status' => $buildObject->getStatus()); /** * restore to system timezone */ $xincTimezone = Xinc_Gui_Handler::getInstance()->getConfigDirective('timezone'); if ($xincTimezone !== null) { Xinc_Timezone::set($xincTimezone); } else { Xinc_Timezone::reset(); } } catch (Exception $e) { // TODO: Handle } } //$builds = array_reverse($builds); $object = new stdClass(); $object->totalcount = $totalCount; $object->builds = $builds; //return new Xinc_Build_Iterator($builds); return $object; }
/** * Get a list of all builds of a project * * @param string $projectName * @param integer $start * @param integer $limit * * @return stdClass */ private function _getLogMessagesArr($projectName, $buildTime, $start, $limit = null) { $statusDir = Xinc_Gui_Handler::getInstance()->getStatusDir(); $historyFile = $statusDir . DIRECTORY_SEPARATOR . $projectName . '.history'; $project = new Xinc_Project(); $project->setName($projectName); $totalCount = 0; try { $build = Xinc_Build::unserialize($project, $buildTime, $statusDir); $timezone = $build->getConfigDirective('timezone'); if ($timezone !== null) { Xinc_Timezone::set($timezone); } $detailDir = Xinc_Build_History::getBuildDir($project, $buildTime); $logXmlFile = $detailDir . DIRECTORY_SEPARATOR . 'buildlog.xml'; if (file_exists($logXmlFile)) { /** * Add fopen() to the function to just get the loglines * that we need. * the bigger the logfiles get, the more this gets a * performance problem */ $xmlStr = ''; $pos = 0; $fh = fopen($logXmlFile, 'r'); $xmlStr = fgets($fh); $xmlStr .= fgets($fh); $tagOpen = false; while ($pos < $start && ($message = $this->_getNextMessage($fh)) !== false) { $pos++; $totalCount++; } if ($limit != null) { $addClosingTag = true; while ($pos < $start + $limit && ($message = $this->_getNextMessage($fh)) !== false) { $xmlStr .= $message; $pos++; $totalCount++; } $xmlStr .= '</build>'; } else { while (($message = $this->_getNextMessage($fh)) !== false) { $xmlStr .= $message; $totalCount++; $pos++; } $xmlStr .= '</build>'; } $tagOpen = false; $tagClosed = false; while (($message = $this->_getNextMessage($fh)) !== false) { $totalCount++; $pos++; } fclose($fh); $logXml = new SimpleXMLElement($xmlStr); } else { $logXml = new SimpleXmlElement('<log/>'); } $totalCount = $pos; //count($logXml->children()); $i = $pos; $logmessages = array(); $id = $totalCount - $start; foreach ($logXml->children() as $logEntry) { $attributes = $logEntry->attributes(); $logmessages[] = array('id' => $id--, 'date' => (string) $attributes->timestamp, 'stringdate' => date('Y-m-d H:i:s', (int) $attributes->timestamp), 'timezone' => Xinc_Timezone::get(), 'priority' => (string) $attributes->priority, 'message' => base64_decode($logEntry)); } /** * restore to system timezone */ $xincTimezone = Xinc_Gui_Handler::getInstance()->getConfigDirective('timezone'); if ($xincTimezone !== null) { Xinc_Timezone::set($xincTimezone); } else { Xinc_Timezone::reset(); } //$logmessages = array_slice($logmessages, $start, $limit, false); } catch (Exception $e1) { $totalCount = 0; $logmessages = array(); } $object = new stdClass(); $object->totalmessages = $totalCount; $object->logmessages = $logmessages; //return new Xinc_Build_Iterator($builds); return $object; }
/** * deletes a build from the history * * @param string $projectName * @param mixed $timestamp Either the integer unix timestamp * or timeformat: "YYYY-MM-DD HH:MI:SS-TZ" */ public static function deleteBuild($projectName, $timestamp) { Xinc_Logger::getInstance()->setLogLevel(0); $project = new Xinc_Project(); $project->setName($projectName); $metaFileArr = self::_loadMetaData($project->getName()); $testTimestamp = (int) $timestamp; if ($testTimestamp . "" != $timestamp) { /** * try and see if we have a string * in format: YYYY-MM-DD HH:MI:SS-TIMEZONE */ $timeParts = split('-', $timestamp); $timeYear = $timeParts[0]; $timeMonth = $timeParts[1]; list($timeDay, $timeTime) = split(' ', $timeParts[2]); $timeZone = $timeParts[3]; $timestamp = strtotime("{$timeYear}-{$timeMonth}-{$timeDay} {$timeTime} {$timeZone}"); } if (!isset($metaFileArr['meta'])) { self::_migrate($project->getName(), $metaFileArr); $metaFileArr = self::_loadMetaData($project->getName()); } $writeMetaFile = false; foreach ($metaFileArr['parts'] as $idx => $part) { if ($part['from'] <= $timestamp && $part['to'] >= $timestamp) { /** * this is the meta file we need */ $partNo = $part['no']; $partArr = self::_readPartFile($project->getName(), $partNo); $newArr = array(); $found = false; $deleteDir = null; $beforeTimestamp = null; $afterTimestamp = null; $lastTimeStamp = null; foreach ($partArr as $compareTimestamp => $serialFileName) { if ($compareTimestamp == $timestamp) { /** * we delete by not adding it again */ $found = true; $deleteDir = dirname($serialFileName); $beforeTimestamp = $lastTimeStamp; $metaFileArr['parts'][$idx]['count'] = $metaFileArr['parts'][$idx]['count'] - 1; $writeMetaFile = true; } else { if ($found && $afterTimestamp == null) { $afterTimestamp = $compareTimestamp; } $newArr[$compareTimestamp] = $serialFileName; } $lastTimeStamp = $compareTimestamp; } //var_dump($deleteDir); //die; if ($found) { try { /** * if this is the only build, we need to delete the part from meta */ if ($timestamp == $part['from'] && $timestamp == $part['to']) { unset($metaFileArr['lastSuccessfulBuild']); unset($metaFileArr['parts'][$idx]); $writeMetaFile = true; } else { if ($timestamp == $part['from']) { if (isset($afterTimestamp)) { $metaFileArr['parts'][$idx]['from'] = $afterTimestamp; $writeMetaFile = true; } } else { if ($timestamp == $part['to']) { if (isset($beforeTimestamp)) { $metaFileArr['parts'][$idx]['to'] = $beforeTimestamp; $writeMetaFile = true; } } } } if ($timestamp == $metaFileArr['lastSuccessfulBuild']['buildtime']) { /** * we need to find the last successful build, before this build */ $reverseMetaArr = array_reverse($metaFileArr['parts'], true); foreach ($metaFileArr['parts'] as $idx => $part) { if ($part['no'] == $partNo) { $testPartArr = $newArr; } else { $testPartArr = self::_readPartFile($project->getName(), $partNo); } $testPartArr = array_reverse($testPartArr, true); foreach ($testPartArr as $testCompareTimestamp => $testSerialFileName) { if (file_exists($testSerialFileName)) { try { $testPart = Xinc_Build::unserialize($project, $testCompareTimestamp, self::_getStatusDir()); } catch (Exception $e) { //var_dump($e); } if ($testPart->getStatus() == Xinc_Build_Interface::PASSED) { $metaFileArr['lastSuccessfulBuild']['buildtime'] = $testCompareTimestamp; $metaFileArr['lastSuccessfulBuild']['filename'] = $testSerialFileName; $writeMetaFile = true; break; } } } } //die; } self::_writePartFile($project->getName(), $partNo, $newArr); Xinc_Logger::getInstance()->info('Successfully written modified metadata'); if ($writeMetaFile) { self::_writeMetaData($projectName, $metaFileArr); Xinc_Logger::getInstance()->info('Successfully written modified meta superdata'); } $deleteDir = realpath($deleteDir); $statusDir = self::_getStatusDir(); $statusDir = realpath($statusDir); /** * make sure we are only deleting inside the status dir */ if (substr($deleteDir, 0, strlen($statusDir)) == $statusDir && strlen($deleteDir) > strlen($statusDir)) { exec('rm -Rf ' . $deleteDir, $output, $res); } else { $res = -1; } //$res = 1; if ($res != 0) { Xinc_Logger::getInstance()->error('Could not delete build directory: ' . $deleteDir); return false; } else { Xinc_Logger::getInstance()->info('Successfully deleted build directory: ' . $deleteDir); return true; } } catch (Exception $e) { Xinc_Logger::getInstance()->error('Could not write modified metadata'); } break; } return false; } } }