Improved build log, added more debug info

This commit is contained in:
Dmitry Khomutov 2016-07-10 14:05:10 +06:00
parent 2548cc2b30
commit 82e73281e4
43 changed files with 248 additions and 88 deletions

View file

@ -220,32 +220,37 @@ class Builder implements LoggerAwareInterface
if ($previous_state == Build::STATUS_FAILED) {
$this->pluginExecutor->executePlugins($this->config, 'fixed');
}
$this->buildLogger->logSuccess(Lang::get('build_success'));
} else {
$this->pluginExecutor->executePlugins($this->config, 'failure');
if ($previous_state == Build::STATUS_SUCCESS || $previous_state == Build::STATUS_NEW) {
$this->pluginExecutor->executePlugins($this->config, 'broken');
}
$this->buildLogger->logFailure(Lang::get('build_failed'));
}
} catch (\Exception $ex) {
$this->build->setStatus(Build::STATUS_FAILED);
$this->buildLogger->logFailure(Lang::get('exception') . $ex->getMessage());
}finally{
// Complete stage plugins are always run
$this->pluginExecutor->executePlugins($this->config, 'complete');
}
if (Build::STATUS_FAILED === $this->build->getStatus()) {
$this->buildLogger->logFailure("\n" . Lang::get('build_failed'));
} else {
$this->buildLogger->logSuccess("\n" . Lang::get('build_success'));
}
try {
// Complete stage plugins are always run
$this->pluginExecutor->executePlugins($this->config, 'complete');
} catch (\Exception $ex) {
$this->buildLogger->logFailure(Lang::get('exception') . $ex->getMessage());
}
// Update the build in the database, ping any external services, etc.
$this->build->sendStatusPostback();
$this->build->setFinished(new \DateTime());
// Clean up:
$this->buildLogger->log(Lang::get('removing_build'));
$this->buildLogger->log("\n" . Lang::get('removing_build'));
$this->build->removeBuildDirectory();
$this->store->save($this->build);
@ -355,8 +360,9 @@ class Builder implements LoggerAwareInterface
$this->buildLogger->log($message, $level, $context);
}
/**
/**
* Add a success-coloured message to the log.
*
* @param string
*/
public function logSuccess($message)
@ -366,6 +372,7 @@ class Builder implements LoggerAwareInterface
/**
* Add a failure-coloured message to the log.
*
* @param string $message
* @param \Exception $exception The exception that caused the error.
*/
@ -373,6 +380,17 @@ class Builder implements LoggerAwareInterface
{
$this->buildLogger->logFailure($message, $exception);
}
/**
* Add a debug message to the log.
*
* @param string
*/
public function logDebug($message)
{
$this->buildLogger->logDebug($message);
}
/**
* Returns a configured instance of the plugin factory.
*

View file

@ -10,6 +10,7 @@
namespace PHPCI\Helper;
use b8\Config;
use PHPCI\Builder;
/**
* Helper class for sending emails using PHPCI's email configuration.
@ -98,11 +99,15 @@ class Email
/**
* Send the email.
*
* @param Builder $phpci
*
* @return bool|int
*/
public function send()
public function send(Builder $phpci)
{
$smtpServer = $this->config->get('phpci.email_settings.smtp_address');
$phpci->logDebug(sprintf("SMTP: '%s'", !empty($smtpServer) ? 'true' : 'false'));
if (empty($smtpServer)) {
return $this->sendViaMail();

View file

@ -195,15 +195,12 @@ PHPCI',
'phpdoccheck_warnings' => 'Missing Docblocks',
'issues' => 'Issues',
'codeception' => 'Codeception',
'phpcpd' => 'PHP Copy/Paste Detector',
'phpcs' => 'PHP Code Sniffer',
'phpdoccheck' => 'Missing Docblocks',
'phpmd' => 'PHP Mess Detector',
'phpspec' => 'PHP Spec',
'phpunit' => 'PHP Unit',
'technical_debt' => 'Technical Debt',
'behat' => 'Behat',
'codeception_feature' => 'Feature',
'codeception_suite' => 'Suite',
@ -419,6 +416,7 @@ PHPCI',
'plugin_missing' => 'Plugin does not exist: %s',
'tap_version' => 'TapParser only supports TAP version 13',
'tap_error' => 'Invalid TAP string, number of tests does not match specified test count.',
'failed_allowed' => 'Allowed',
// Build Plugins:
'no_tests_performed' => 'No tests have been performed.',
@ -453,9 +451,37 @@ PHPCI',
'low' => 'Low',
// Plugins that generate errors:
'php_mess_detector' => 'PHP Mess Detector',
'php_code_sniffer' => 'PHP Code Sniffer',
'php_unit' => 'PHP Unit',
'php_cpd' => 'PHP Copy/Paste Detector',
'php_mess_detector' => 'PHP Mess Detector',
'php_code_sniffer' => 'PHP Code Sniffer',
'php_unit' => 'PHP Unit',
'php_cpd' => 'PHP Copy/Paste Detector',
'php_docblock_checker' => 'PHP Docblock Checker',
'composer' => 'Composer',
'php_loc' => 'PHPLOC',
'php_parallel_lint' => 'PHP Parallel Lint',
'email' => 'Email',
'atoum' => 'Atoum',
'behat' => 'Behat',
'campfire' => 'Campfire',
'clean_build' => 'Clean Build',
'codeception' => 'Codeception',
'copy_build' => 'Copy Build',
'deployer' => 'Deployer',
'env' => 'Env',
'grunt' => 'Grunt',
'hipchat_notify' => 'Hipchat',
'irc' => 'IRC',
'lint' => 'Lint',
'mysql' => 'MySQL',
'package_build' => 'Package Build',
'pdepend' => 'PDepend',
'pgsql' => 'PostgreSQL',
'phar' => 'Phar',
'phing' => 'Phing',
'php_cs_fixer' => 'PHP Coding Standards Fixer',
'php_spec' => 'PHP Spec',
'shell' => 'Shell',
'slack_notify' => 'Slack',
'technical_debt' => 'Technical Debt',
'xmpp' => 'XMPP',
];

View file

@ -187,15 +187,12 @@ PHPCI',
'phpdoccheck_warnings' => 'Пропущенные Docblocks',
'issues' => 'Проблемы',
'codeception' => 'Codeception',
'phpcpd' => 'PHP Copy/Paste Detector',
'phpcs' => 'PHP Code Sniffer',
'phpdoccheck' => 'Missing Docblocks',
'phpmd' => 'PHP Mess Detector',
'phpspec' => 'PHP Spec',
'phpunit' => 'PHP Unit',
'technical_debt' => 'Технические долги',
'behat' => 'Behat',
'codeception_feature' => 'Свойство',
'codeception_suite' => 'Набор',
@ -405,6 +402,7 @@ PHPCI',
'plugin_missing' => 'Плагина не существует: %s',
'tap_version' => 'TapParser поддерживает только TAP версии 13',
'tap_error' => 'Некорректная TAP-строка, количество тестов не совпадает с заявленным.',
'failed_allowed' => 'Разрешен',
// Build Plugins:
'no_tests_performed' => 'Никакие тесты не были запущены.',
@ -438,9 +436,37 @@ PHPCI',
'low' => 'Низкий',
// Plugins that generate errors:
'php_mess_detector' => 'PHP Mess Detector',
'php_code_sniffer' => 'PHP Code Sniffer',
'php_unit' => 'PHP Unit',
'php_cpd' => 'PHP Copy/Paste Detector',
'php_mess_detector' => 'PHP Mess Detector',
'php_code_sniffer' => 'PHP Code Sniffer',
'php_unit' => 'PHP Unit',
'php_cpd' => 'PHP Copy/Paste Detector',
'php_docblock_checker' => 'PHP Docblock Checker',
'composer' => 'Composer',
'php_loc' => 'PHPLOC',
'php_parallel_lint' => 'PHP Parallel Lint',
'email' => 'Email',
'atoum' => 'Atoum',
'behat' => 'Behat',
'campfire' => 'Campfire',
'clean_build' => 'Clean Build',
'codeception' => 'Codeception',
'copy_build' => 'Copy Build',
'deployer' => 'Deployer',
'env' => 'Env',
'grunt' => 'Grunt',
'hipchat_notify' => 'Hipchat',
'irc' => 'IRC',
'lint' => 'Lint',
'mysql' => 'MySQL',
'package_build' => 'Package Build',
'pdepend' => 'PDepend',
'pgsql' => 'PostgreSQL',
'phar' => 'Phar',
'phing' => 'Phing',
'php_cs_fixer' => 'PHP Coding Standards Fixer',
'php_spec' => 'PHP Spec',
'shell' => 'Shell',
'slack_notify' => 'Slack',
'technical_debt' => 'Technical Debt',
'xmpp' => 'XMPP',
];

View file

@ -91,11 +91,7 @@ class BuildLogger implements LoggerAwareInterface
$context['exception'] = $exception;
}
$this->log(
"\033[0;31m" . $message . "\033[0m",
LogLevel::ERROR,
$context
);
$this->log("\033[0;31m" . $message . "\033[0m", LogLevel::ERROR, $context);
}
/**
@ -105,7 +101,7 @@ class BuildLogger implements LoggerAwareInterface
public function logDebug($message)
{
if (defined('PHPCI_DEBUG_MODE') && PHPCI_DEBUG_MODE) {
$this->log("\033[0;33m" . $message . "\033[0m");
$this->log("\033[0;36m" . $message . "\033[0m");
}
}

View file

@ -190,7 +190,7 @@ class BuildBase extends Model
*/
public function getId()
{
$rtn = $this->data['id'];
$rtn = $this->data['id'];
return $rtn;
}
@ -202,7 +202,7 @@ class BuildBase extends Model
*/
public function getProjectId()
{
$rtn = $this->data['project_id'];
$rtn = $this->data['project_id'];
return $rtn;
}
@ -214,7 +214,7 @@ class BuildBase extends Model
*/
public function getCommitId()
{
$rtn = $this->data['commit_id'];
$rtn = $this->data['commit_id'];
return $rtn;
}
@ -226,7 +226,7 @@ class BuildBase extends Model
*/
public function getStatus()
{
$rtn = $this->data['status'];
$rtn = $this->data['status'];
return $rtn;
}
@ -238,7 +238,7 @@ class BuildBase extends Model
*/
public function getLog()
{
$rtn = $this->data['log'];
$rtn = $this->data['log'];
return $rtn;
}
@ -250,7 +250,7 @@ class BuildBase extends Model
*/
public function getBranch()
{
$rtn = $this->data['branch'];
$rtn = $this->data['branch'];
return $rtn;
}
@ -262,10 +262,10 @@ class BuildBase extends Model
*/
public function getCreated()
{
$rtn = $this->data['created'];
$rtn = $this->data['created'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
$rtn = new \DateTime($rtn);
}
return $rtn;
@ -278,10 +278,10 @@ class BuildBase extends Model
*/
public function getStarted()
{
$rtn = $this->data['started'];
$rtn = $this->data['started'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
$rtn = new \DateTime($rtn);
}
return $rtn;
@ -294,10 +294,10 @@ class BuildBase extends Model
*/
public function getFinished()
{
$rtn = $this->data['finished'];
$rtn = $this->data['finished'];
if (!empty($rtn)) {
$rtn = new \DateTime($rtn);
$rtn = new \DateTime($rtn);
}
return $rtn;
@ -310,7 +310,7 @@ class BuildBase extends Model
*/
public function getCommitterEmail()
{
$rtn = $this->data['committer_email'];
$rtn = $this->data['committer_email'];
return $rtn;
}
@ -322,7 +322,7 @@ class BuildBase extends Model
*/
public function getCommitMessage()
{
$rtn = $this->data['commit_message'];
$rtn = $this->data['commit_message'];
return $rtn;
}
@ -334,7 +334,7 @@ class BuildBase extends Model
*/
public function getExtra()
{
$rtn = $this->data['extra'];
$rtn = $this->data['extra'];
return $rtn;
}
@ -580,11 +580,11 @@ class BuildBase extends Model
return null;
}
$cacheKey = 'Cache.Project.' . $key;
$rtn = $this->cache->get($cacheKey, null);
$cacheKey = 'Cache.Project.' . $key;
$rtn = $this->cache->get($cacheKey, null);
if (empty($rtn)) {
$rtn = Factory::getStore('Project', 'PHPCI')->getById($key);
$rtn = Factory::getStore('Project', 'PHPCI')->getById($key);
$this->cache->set($cacheKey, $rtn);
}

View file

@ -298,4 +298,17 @@ class Build extends BuildBase
return $end->getTimestamp() - $start->getTimestamp();
}
/**
* Create a working copy by cloning, copying, or similar.
*
* @param Builder $builder
* @param string $buildPath
*
* @return boolean
*/
public function createWorkingCopy(Builder $builder, $buildPath)
{
return false;
}
}

View file

@ -54,6 +54,8 @@ class Behat implements Plugin
if (!empty($options['features'])) {
$this->features = $options['features'];
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -55,7 +55,6 @@ class Campfire implements Plugin
} else {
throw new \Exception(Lang::get('no_campfire_settings'));
}
}
/**

View file

@ -43,6 +43,8 @@ class CleanBuild implements Plugin
$this->phpci = $phpci;
$this->build = $build;
$this->remove = isset($options['remove']) && is_array($options['remove']) ? $options['remove'] : [];
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -98,6 +98,8 @@ class Codeception implements Plugin, ZeroConfigPlugin
if (isset($options['path'])) {
$this->path = $options['path'];
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -90,6 +90,8 @@ class Composer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
if (array_key_exists('ignore_platform_reqs', $options)) {
$this->ignorePlatformReqs = (bool)$options['ignore_platform_reqs'];
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -42,6 +42,8 @@ class CopyBuild implements Plugin
$this->directory = isset($options['directory']) ? $options['directory'] : $path;
$this->wipe = isset($options['wipe']) ? (bool)$options['wipe'] : false;
$this->ignore = isset($options['respect_ignore']) ? (bool)$options['respect_ignore'] : false;
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -43,18 +43,16 @@ class Email implements Plugin
/**
* Set up the plugin, configure options, etc.
* @param Builder $phpci
* @param Build $build
* @param \Swift_Mailer $mailer
* @param array $options
* @param Build $build
* @param array $options
*/
public function __construct(
Builder $phpci,
Build $build,
array $options = []
) {
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
$this->options = $options;
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**
@ -83,14 +81,14 @@ class Email implements Plugin
$view = $this->getDefaultMailTemplate();
}
$view->build = $this->build;
$view->build = $this->build;
$view->project = $this->build->getProject();
$layout = new View('Email/layout');
$layout->build = $this->build;
$layout = new View('Email/layout');
$layout->build = $this->build;
$layout->project = $this->build->getProject();
$layout->content = $view->render();
$body = $layout->render();
$body = $layout->render();
$sendFailures = $this->sendSeparateEmails(
$addresses,
@ -127,7 +125,7 @@ class Email implements Plugin
}
}
return $email->send();
return $email->send($this->phpci);
}
/**
@ -145,13 +143,14 @@ class Email implements Plugin
public function sendSeparateEmails(array $toAddresses, $subject, $body)
{
$failures = 0;
$ccList = $this->getCcAddresses();
$ccList = $this->getCcAddresses();
foreach ($toAddresses as $address) {
if (!$this->sendEmail($address, $ccList, $subject, $body)) {
$failures++;
}
}
return $failures;
}
@ -164,17 +163,35 @@ class Email implements Plugin
$addresses = [];
$committer = $this->build->getCommitterEmail();
if (isset($this->options['committer']) && !empty($committer)) {
$addresses[] = $committer;
$this->phpci->logDebug(sprintf("Committer email: '%s'", $committer));
$this->phpci->logDebug(sprintf(
"Committer option: '%s'",
(!empty($this->options['committer']) && $this->options['committer']) ? 'true' : 'false'
));
if (!empty($this->options['committer']) && $this->options['committer']) {
if ($committer) {
$addresses[] = $committer;
}
}
if (isset($this->options['addresses'])) {
$this->phpci->logDebug(sprintf(
"Addresses option: '%s'",
(!empty($this->options['addresses']) && is_array($this->options['addresses'])) ? implode(', ', $this->options['addresses']) : 'false'
));
if (!empty($this->options['addresses']) && is_array($this->options['addresses'])) {
foreach ($this->options['addresses'] as $address) {
$addresses[] = $address;
}
}
if (empty($addresses) && isset($this->options['default_mailto_address'])) {
$this->phpci->logDebug(sprintf(
"Default mailTo option: '%s'",
!empty($this->options['default_mailto_address']) ? $this->options['default_mailto_address'] : 'false'
));
if (empty($addresses) && !empty($this->options['default_mailto_address'])) {
$addresses[] = $this->options['default_mailto_address'];
}

View file

@ -34,9 +34,11 @@ class Env implements Plugin
*/
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
$this->phpci = $phpci;
$this->build = $build;
$this->env_vars = $options;
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -34,9 +34,11 @@ class Git implements Plugin
*/
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
$this->phpci = $phpci;
$this->build = $build;
$this->actions = $options;
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -67,6 +67,8 @@ class Grunt implements Plugin
if (isset($options['gruntfile'])) {
$this->gruntfile = $options['gruntfile'];
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -67,6 +67,8 @@ class Gulp implements Plugin
if (isset($options['gulpfile'])) {
$this->gulpfile = $options['gulpfile'];
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -66,7 +66,6 @@ class HipchatNotify implements Plugin
} else {
throw new \Exception(Lang::get('hipchat_settings'));
}
}
/**

View file

@ -59,6 +59,8 @@ class Irc implements Plugin
$this->room = $irc['room'];
$this->nick = $irc['nick'];
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -57,6 +57,8 @@ class Lint implements PHPCI\Plugin
if (array_key_exists('recursive', $options)) {
$this->recursive = $options['recursive'];
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -90,6 +90,8 @@ class Mysql implements Plugin
if (array_key_exists('pass', $buildSettings['mysql'])) {
$this->pass = $buildSettings['mysql']['pass'];
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -40,6 +40,8 @@ class PackageBuild implements Plugin
$this->directory = isset($options['directory']) ? $options['directory'] : $path;
$this->filename = isset($options['filename']) ? $options['filename'] : 'build';
$this->format = isset($options['format']) ? $options['format'] : 'zip';
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -66,6 +66,8 @@ class Pdepend implements Plugin
$this->pyramid = $title . '-pyramid.svg';
$this->chart = $title . '-chart.svg';
$this->location = $this->phpci->buildPath . '..' . DIRECTORY_SEPARATOR . 'pdepend';
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -71,6 +71,8 @@ class Pgsql implements Plugin
$this->user = $sql['user'];
$this->pass = $sql['pass'];
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -87,6 +87,8 @@ class Phar implements Plugin
if (isset($options['stub'])) {
$this->setStub($options['stub']);
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -126,6 +126,8 @@ class PhpCodeSniffer implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
}
$this->setOptions($options);
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -65,6 +65,8 @@ class PhpCpd implements Plugin
if (!empty($options['ignore'])) {
$this->ignore = $options['ignore'];
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -56,6 +56,8 @@ class PhpCsFixer implements Plugin
$this->workingdir = $this->phpci->buildPath;
$this->buildArgs($options);
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -94,6 +94,8 @@ class PhpDocblockChecker implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
if (array_key_exists('allowed_warnings', $options)) {
$this->allowed_warnings = (int)$options['allowed_warnings'];
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -61,6 +61,8 @@ class PhpLoc implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
if (isset($options['directory'])) {
$this->directory .= $options['directory'];
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -108,6 +108,8 @@ class PhpMessDetector implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
foreach (['rules', 'ignore', 'suffixes'] as $key) {
$this->overrideSetting($options, $key);
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -67,6 +67,8 @@ class PhpParallelLint implements Plugin
if (isset($options['ignore'])) {
$this->ignore = $options['ignore'];
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -44,9 +44,11 @@ class PhpSpec implements PHPCI\Plugin
*/
public function __construct(Builder $phpci, Build $build, array $options = [])
{
$this->phpci = $phpci;
$this->build = $build;
$this->phpci = $phpci;
$this->build = $build;
$this->options = $options;
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -83,6 +83,8 @@ class PhpTalLint implements PHPCI\Plugin
}
$this->setOptions($options);
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -135,6 +135,8 @@ class PhpUnit implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
if (isset($options['coverage'])) {
$this->coverage = ' --coverage-html ' . $this->phpci->interpolate($options['coverage']) . ' ';
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -72,6 +72,8 @@ class Shell implements Plugin
if (is_array($options)) {
$this->commands = $options;
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -58,6 +58,8 @@ class Sqlite implements Plugin
$sql = $buildSettings['sqlite'];
$this->path = $sql['path'];
}
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -101,6 +101,8 @@ class TechnicalDebt implements PHPCI\Plugin, PHPCI\ZeroConfigPlugin
}
$this->setOptions($options);
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -78,7 +78,7 @@ class Executor
protected function getBranchSpecificPlugins(&$config, $stage, $pluginsToExecute)
{
/** @var \PHPCI\Model\Build $build */
$build = $this->pluginFactory->getResourceFor('PHPCI\Model\Build');
$build = $this->pluginFactory->getResourceFor('PHPCI\Model\Build');
$branch = $build->getBranch();
// If we don't have any branch-specific plugins:
@ -133,7 +133,7 @@ class Executor
$success = true;
foreach ($plugins as $plugin => $options) {
$this->logger->log(Lang::get('running_plugin', $plugin));
$this->logger->log("\n" . Lang::get('running_plugin', Lang::get($plugin)) . ' (' . Lang::get('stage') . ': ' . Lang::get('stage_' . $stage) . ')');
$this->setPluginStatus($stage, $plugin, Build::STATUS_RUNNING);
@ -144,18 +144,21 @@ class Executor
$this->setPluginStatus($stage, $plugin, Build::STATUS_SUCCESS);
} else {
// Execution failed
$this->logger->logFailure(Lang::get('plugin_failed'));
$this->setPluginStatus($stage, $plugin, Build::STATUS_FAILED);
if ($stage === 'setup') {
$this->logger->logFailure(Lang::get('plugin_failed'));
// If we're in the "setup" stage, execution should not continue after
// a plugin has failed:
throw new Exception('Plugin failed: ' . $plugin);
} elseif ($stage === 'test') {
} else {
// If we're in the "test" stage and the plugin is not allowed to fail,
// then mark the build as failed:
if (empty($options['allow_failures'])) {
if (empty($options['allow_failures']) && $stage === 'test') {
$this->logger->logFailure(Lang::get('plugin_failed'));
$success = false;
} else {
$this->logger->logFailure(Lang::get('plugin_failed') . ' (' . Lang::get('failed_allowed') . ')');
}
}
}
@ -182,15 +185,18 @@ class Executor
if (!class_exists($class)) {
$this->logger->logFailure(Lang::get('plugin_missing', $plugin));
return false;
}
try {
// Build and run it
$obj = $this->pluginFactory->buildPlugin($class, $options);
return $obj->execute();
} catch (\Exception $ex) {
$this->logger->logFailure(Lang::get('exception') . $ex->getMessage(), $ex);
return false;
}
}
@ -228,6 +234,7 @@ class Executor
*/
private function getBuildSummary()
{
/** @var Build $build */
$build = $this->pluginFactory->getResourceFor('PHPCI\Model\Build');
$metas = $this->store->getMeta('plugin-summary', $build->getProjectId(), $build->getId());
return isset($metas[0]['meta_value']) ? $metas[0]['meta_value'] : [];
@ -240,6 +247,7 @@ class Executor
*/
private function setBuildSummary($summary)
{
/** @var Build $build */
$build = $this->pluginFactory->getResourceFor('PHPCI\Model\Build');
$this->store->setMeta($build->getProjectId(), $build->getId(), 'plugin-summary', json_encode($summary));
}

View file

@ -31,15 +31,6 @@ class Factory
} else {
$this->container = new Container();
}
$self = $this;
$this->registerResource(
function () use ($self) {
return $self->getLastOptions();
},
'options',
'array'
);
}
/**

View file

@ -45,6 +45,8 @@ class Wipe implements Plugin
$this->phpci = $phpci;
$this->build = $build;
$this->directory = isset($options['directory']) ? $this->phpci->interpolate($options['directory']) : $path;
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**

View file

@ -91,6 +91,8 @@ class XMPP implements Plugin
}
$this->setOptions($options);
$this->phpci->logDebug('Plugin options: ' . json_encode($options));
}
/**