/** * 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) { $build->debug('Setting property "${' . $this->_name . '}" to "' . $this->_value . '"'); //$build->getProperties()->set($this->_name, $this->_value); }