Now builds artifacts remove when remove build and project. Issue #107.
This commit is contained in:
parent
3ec111da24
commit
0fc2a66678
6 changed files with 149 additions and 45 deletions
|
|
@ -5,6 +5,7 @@ namespace PHPCensor\Plugin;
|
|||
use PHPCensor\Builder;
|
||||
use PHPCensor\Model\Build;
|
||||
use PHPCensor\Plugin;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
|
||||
/**
|
||||
* Pdepend Plugin - Allows Pdepend report
|
||||
|
|
@ -20,6 +21,11 @@ class Pdepend extends Plugin
|
|||
*/
|
||||
protected $buildDirectory;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $buildBranchDirectory;
|
||||
|
||||
/**
|
||||
* @var string Directory which needs to be scanned
|
||||
*/
|
||||
|
|
@ -41,10 +47,14 @@ class Pdepend extends Plugin
|
|||
protected $pyramid;
|
||||
|
||||
/**
|
||||
* @var string Location on the server where the files are stored. Preferably in the webroot for inclusion
|
||||
* in the readme.md of the repository
|
||||
* @var string
|
||||
*/
|
||||
protected $location;
|
||||
protected $buildLocation;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $buildBranchLocation;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
|
|
@ -69,8 +79,11 @@ class Pdepend extends Plugin
|
|||
$this->pyramid = 'pyramid.svg';
|
||||
$this->chart = 'chart.svg';
|
||||
|
||||
$this->buildDirectory = $build->getProjectId() . '/' . $build->getId();
|
||||
$this->location = PUBLIC_DIR . 'artifacts/pdepend/' . $this->buildDirectory;
|
||||
$this->buildDirectory = $build->getBuildDirectory();
|
||||
$this->buildBranchDirectory = $build->getBuildBranchDirectory();
|
||||
|
||||
$this->buildLocation = PUBLIC_DIR . 'artifacts/pdepend/' . $this->buildDirectory;
|
||||
$this->buildBranchLocation = PUBLIC_DIR . 'artifacts/pdepend/' . $this->buildBranchDirectory;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -78,11 +91,11 @@ class Pdepend extends Plugin
|
|||
*/
|
||||
public function execute()
|
||||
{
|
||||
if (!file_exists($this->location)) {
|
||||
mkdir($this->location, (0777 & ~umask()), true);
|
||||
if (!file_exists($this->buildLocation)) {
|
||||
mkdir($this->buildLocation, (0777 & ~umask()), true);
|
||||
}
|
||||
if (!is_writable($this->location)) {
|
||||
throw new \Exception(sprintf('The location %s is not writable or does not exist.', $this->location));
|
||||
if (!is_writable($this->buildLocation)) {
|
||||
throw new \Exception(sprintf('The location %s is not writable or does not exist.', $this->buildLocation));
|
||||
}
|
||||
|
||||
$pdepend = $this->findBinary('pdepend');
|
||||
|
|
@ -100,22 +113,32 @@ class Pdepend extends Plugin
|
|||
|
||||
$success = $this->builder->executeCommand(
|
||||
$cmd,
|
||||
$this->location . DIRECTORY_SEPARATOR . $this->summary,
|
||||
$this->location . DIRECTORY_SEPARATOR . $this->chart,
|
||||
$this->location . DIRECTORY_SEPARATOR . $this->pyramid,
|
||||
$this->buildLocation . DIRECTORY_SEPARATOR . $this->summary,
|
||||
$this->buildLocation . DIRECTORY_SEPARATOR . $this->chart,
|
||||
$this->buildLocation . DIRECTORY_SEPARATOR . $this->pyramid,
|
||||
$ignore,
|
||||
$this->directory
|
||||
);
|
||||
|
||||
$fileSystem = new Filesystem();
|
||||
|
||||
if (file_exists($this->buildLocation)) {
|
||||
$fileSystem->remove($this->buildBranchLocation);
|
||||
$fileSystem->mirror($this->buildLocation, $this->buildBranchLocation);
|
||||
}
|
||||
|
||||
$config = $this->builder->getSystemConfig('php-censor');
|
||||
|
||||
if ($success) {
|
||||
$this->builder->logSuccess(
|
||||
sprintf(
|
||||
"\nPdepend successful.\nYou can use: %s,\n and\n\nfor inclusion in the readme.md file",
|
||||
"\nPdepend successful build report.\nYou can use report for this build for inclusion in the readme.md file:\n%s,\n and\n\n\nOr report for last build in the branch:\n%s,\n and\n\n",
|
||||
$config['url'] . '/artifacts/pdepend/' . $this->buildDirectory . '/' . $this->summary,
|
||||
$config['url'] . '/artifacts/pdepend/' . $this->buildDirectory . '/' . $this->chart,
|
||||
$config['url'] . '/artifacts/pdepend/' . $this->buildDirectory . '/' . $this->pyramid
|
||||
$config['url'] . '/artifacts/pdepend/' . $this->buildDirectory . '/' . $this->pyramid,
|
||||
$config['url'] . '/artifacts/pdepend/' . $this->buildBranchDirectory . '/' . $this->summary,
|
||||
$config['url'] . '/artifacts/pdepend/' . $this->buildBranchDirectory . '/' . $this->chart,
|
||||
$config['url'] . '/artifacts/pdepend/' . $this->buildBranchDirectory . '/' . $this->pyramid
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -130,8 +153,8 @@ class Pdepend extends Plugin
|
|||
{
|
||||
//Remove the created files first
|
||||
foreach ([$this->summary, $this->chart, $this->pyramid] as $file) {
|
||||
if (file_exists($this->location . DIRECTORY_SEPARATOR . $file)) {
|
||||
unlink($this->location . DIRECTORY_SEPARATOR . $file);
|
||||
if (file_exists($this->buildLocation . DIRECTORY_SEPARATOR . $file)) {
|
||||
unlink($this->buildLocation . DIRECTORY_SEPARATOR . $file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue