Moved handleConfig functionality into general Build method.
This commit is contained in:
parent
60bf262ee7
commit
ea35f24d47
|
@ -11,6 +11,8 @@ namespace PHPCI\Model;
|
|||
|
||||
use b8\Store\Factory;
|
||||
use PHPCI\Model\Base\BuildBase;
|
||||
use PHPCI\Builder;
|
||||
use Symfony\Component\Yaml\Parser as YamlParser;
|
||||
|
||||
/**
|
||||
* Build Model
|
||||
|
@ -77,4 +79,26 @@ class Build extends BuildBase
|
|||
{
|
||||
return ($this->getStatus() === self::STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Builder $builder
|
||||
* @param string $buildPath
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function handleConfig(Builder $builder, $buildPath)
|
||||
{
|
||||
$build_config = $this->getProject()->getBuildConfig();
|
||||
if (!$build_config) {
|
||||
if (!is_file($buildPath . '/phpci.yml')) {
|
||||
$builder->logFailure('Project does not contain a phpci.yml file.');
|
||||
return false;
|
||||
}
|
||||
$build_config = file_get_contents($buildPath . '/phpci.yml');
|
||||
}
|
||||
|
||||
$yamlParser = new YamlParser();
|
||||
$builder->setConfigArray($yamlParser->parse($build_config));
|
||||
return $builder->getConfig('build_settings');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ namespace PHPCI\Model\Build;
|
|||
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\Builder;
|
||||
use Symfony\Component\Yaml\Parser as YamlParser;
|
||||
|
||||
/**
|
||||
* Local Build Model
|
||||
|
@ -83,21 +82,4 @@ class LocalBuild extends Build
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function handleConfig(Builder $builder, $reference)
|
||||
{
|
||||
$build_config = $this->getProject()->getBuildConfig();
|
||||
if (!$build_config)
|
||||
{
|
||||
if (!is_file($reference . '/phpci.yml')) {
|
||||
$builder->logFailure('Project does not contain a phpci.yml file.');
|
||||
return false;
|
||||
}
|
||||
$build_config = file_get_contents($reference . '/phpci.yml');
|
||||
}
|
||||
|
||||
$yamlParser = new YamlParser();
|
||||
$builder->setConfigArray($yamlParser->parse($build_config));
|
||||
return $builder->getConfig('build_settings');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ namespace PHPCI\Model\Build;
|
|||
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\Builder;
|
||||
use Symfony\Component\Yaml\Parser as YamlParser;
|
||||
|
||||
/**
|
||||
* Mercurial Build Model
|
||||
|
@ -36,20 +35,7 @@ class MercurialBuild extends Build
|
|||
{
|
||||
$this->cloneByHttp($builder, $buildPath);
|
||||
|
||||
$build_config = $this->getProject()->getBuildConfig();
|
||||
if (!$build_config)
|
||||
{
|
||||
if (!is_file($buildPath . '/phpci.yml')) {
|
||||
$builder->logFailure('Project does not contain a phpci.yml file.');
|
||||
return false;
|
||||
}
|
||||
$build_config = file_get_contents($buildPath . '/phpci.yml');
|
||||
}
|
||||
|
||||
$yamlParser = new YamlParser();
|
||||
$builder->setConfigArray($yamlParser->parse($build_config));
|
||||
|
||||
return true;
|
||||
return $this->handleConfig($builder, $buildPath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,7 +11,6 @@ namespace PHPCI\Model\Build;
|
|||
|
||||
use PHPCI\Model\Build;
|
||||
use PHPCI\Builder;
|
||||
use Symfony\Component\Yaml\Parser as YamlParser;
|
||||
|
||||
/**
|
||||
* Remote Git Build Model
|
||||
|
@ -47,20 +46,7 @@ class RemoteGitBuild extends Build
|
|||
return false;
|
||||
}
|
||||
|
||||
$build_config = $this->getProject()->getBuildConfig();
|
||||
if (!$build_config)
|
||||
{
|
||||
if (!is_file($buildPath . '/phpci.yml')) {
|
||||
$builder->logFailure('Project does not contain a phpci.yml file.');
|
||||
return false;
|
||||
}
|
||||
$build_config = file_get_contents($buildPath . '/phpci.yml');
|
||||
}
|
||||
|
||||
$yamlParser = new YamlParser();
|
||||
$builder->setConfigArray($yamlParser->parse($build_config));
|
||||
|
||||
return true;
|
||||
return $this->handleConfig($builder, $buildPath);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue