protected function setupConfigProperties(BuildInterface $build) { $options = array('workingdir', 'projectdir', 'statusdir'); foreach ($options as $option) { $build->setProperty($option, $this->config->get($option)); } }
/** * Return the label for this build. * * @param Xinc_Build_Interface $build * * @return string */ public function getLabel(BuildInterface $build) { $buildNo = $build->getNumber(); if ($buildNo == null) { $buildNo = $this->_firstBuild; } $buildLabel = $this->_prefix . $buildNo; $build->setProperty('build.label', $buildLabel); return $buildLabel; }
/** * Calculates the next build timestamp * this is a build once scheduler. * * @return int */ public function getNextBuildTime(BuildInterface $build) { if ($build->getLastBuild()->getBuildTime() == null && $build->getStatus() !== BuildInterface::STOPPED) { if (!isset($this->_nextBuildTime)) { $this->_nextBuildTime = time(); } return $this->_nextBuildTime; } else { return; } }
/** * loads properties from a property file. * * @param BuildInterface $build * @param string $fileName */ public function parsePropertyFile(BuildInterface $build, $fileName) { $activeProperty = false; $trimNextLine = false; $arr = array(); $fh = fopen($fileName, 'r'); if (is_resource($fh)) { while ($line = fgets($fh)) { if (preg_match('/^[!#].*/', $line)) { // comment } elseif (preg_match("/^.*?([\\._-\\w]+?)\\s*[=:]+\\s*(.*)\$/", $line, $matches)) { // we have a key definition $activeProperty = true; $key = $matches[1]; $valuePart = $matches[2]; $arr[$key] = trim($valuePart); if ($arr[$key][strlen($arr[$key]) - 1] == '\\') { $arr[$key] = substr($arr[$key], 0, -1); $trimNextLine = true; } else { $trimNextLine = false; } } elseif ($activeProperty) { $trimmed = trim($line); if (empty($trimmed)) { $activeProperty = false; continue; } elseif ($trimNextLine) { $line = $trimmed; } else { $line = rtrim($line); } $arr[$key] .= "\n" . $line; if ($arr[$key][strlen($arr[$key]) - 1] == '\\') { $arr[$key] = substr($arr[$key], 0, -1); $trimNextLine = true; } else { $trimNextLine = false; } } } foreach ($arr as $key => $value) { $build->debug('Setting property "${' . $key . '}" to "' . $value . '"'); $build->setProperty($key, stripcslashes($value)); } } else { $build->error('Cannot read from property file: ' . $fileName); } }
public function getNextBuildTime(BuildInterface $build) { if ($build->getStatus() == BuildInterface::STOPPED) { return null; } //var_dump($build); $lastBuild = $build->getLastBuild()->getBuildTime(); if ($lastBuild == null) { $lastBuild = 0; } //$nextBuild = $this->getLastScheduledRunTime($this->timer . ' test',$lastBuild); $nextBuild = $this->getTimeFromCron($lastBuild); $build->debug('getNextBuildTime:' . ' lastbuild: ' . date('Y-m-d H:i:s', $lastBuild) . ' nextbuild: ' . date('Y-m-d H:i:s', $nextBuild)); return $nextBuild; }
public function process(BuildInterface $build) { foreach ($this->results as $result) { $build->info($result); if ($result->getStatus() == Result::CHANGED) { $build->setStatus(BuildInterface::PASSED); break; } else { if ($result->getStatus() === Result::STOPPED) { $build->setStatus(BuildInterface::STOPPED); } else { if ($result->getStatus() === Result::FAILED) { $build->setStatus(BuildInterface::FAILED); } else { if ($result->getStatus() === Result::ERROR) { $build->setStatus(BuildInterface::STOPPED); break; } else { $build->setStatus(BuildInterface::STOPPED); } } } } return; } }
public function getNextBuildTime(BuildInterface $build) { if ($build->getStatus() == BuildInterface::STOPPED) { return null; } $lastBuild = $build->getLastBuild()->getBuildTime(); if ($lastBuild !== null) { $nextBuild = $this->getInterval() + $lastBuild; /** * Make sure that we dont rerun every build if the daemon was paused */ //echo time(). ' - ' . $lastBuild .'='.(time()-$lastBuild)."\n"; if ($nextBuild + $this->getInterval() < time()) { $nextBuild = time(); } } else { // never ran, schedule for now $nextBuild = time(); } $this->log->debug('getNextBuildTime ' . ': lastbuild: ' . date('Y-m-d H:i:s', $lastBuild) . ' nextbuild: ' . date('Y-m-d H:i:s', $nextBuild) . ''); return $nextBuild; }
public function process(BuildInterface $build) { $build->info('Processing publishers done'); }
public function init(BuildInterface $build) { $build->setScheduler($this); }
/** * Check if this modification set has been modified * * @param BuildInterface $build The running build. * @return Xinc::Core::Plugin::ModificationSet::Result The result of the check. */ public function checkModified(BuildInterface $build) { $result = new Result(); $result->setSource(get_class($this)); try { $this->initSvn(); $strRemoteVersion = $this->getRemoteVersion(); $strLocalVersion = $this->getLocalVersion(); } catch (\VersionControl_SVN_Exception $e) { $build->error('Test of Subversion failed: ' . $e->getMessage()); $build->setStatus(BuildInterface::FAILED); $result->setStatus(Result::ERROR); return $result; } $result->setRemoteRevision($strRemoteVersion); $result->setLocalRevision($strLocalVersion); if ($strRemoteVersion !== $strLocalVersion) { try { $this->getModifiedFiles($result); $this->getChangeLog($result); if ($this->doUpdate()) { $this->update($result); } $result->setStatus(Result::CHANGED); } catch (Exception $e) { $build->error('Processing SVN failed: ' . $e->getMessage()); $result->setStatus(Result::FAILED); } } return $result; }
public function configure(BuildInterface $build) { $build->setConfigDirective($this->name, $this->value); }
public function set(BuildInterface $build, $value) { $newvalue = $build->parseProperty($value); return $newvalue; }
public function process(BuildInterface $build) { if ($this->_if !== null) { /* * If we have a condition, we need to check */ $property = $build->getProperty($this->_if); if ($property !== true) { $build->info('Property: ' . $this->_name . ' does not apply, ' . $this->_if . ' == false'); $build->setStatus(BuildInterface::PASSED); return; } } if (isset($this->_file)) { if (file_exists($this->_file)) { $build->info('Reading property file: ' . $this->_file); $this->_plugin->parsePropertyFile($build, $this->_file); } elseif (strstr($this->_file, '${')) { // not substituted yet, will not use it } else { $build->error('Cannot read property file: ' . $this->_file); } } else { $build->debug('Setting property "${' . $this->_name . '}" to "' . $this->_value . '"'); $build->getProperties()->set($this->_name, $this->_value); $build->setStatus(BuildInterface::PASSED); } }