无法使用Jenkins,Symfony3和PHPUnit 5.3完成构建

时间:2016-05-02 22:10:15

标签: symfony jenkins phpunit

尝试学习CI,我遇到了以下问题: 命令行中的Ant提供了“成功”的功能。信息。 当我将代码推送到GitHub并在AWS上运行Jenkins时,evth传递除了PHPUnit部分错误:

> phpunit:
[phpunit] PHP Warning: require(/var/lib/jenkins/workspace/mavajob/app/../vendor/autoload.php): failed to open stream: No such file or directory in /var/lib/jenkins/workspace/mavajob/app/autoload.php on line 9
[phpunit] PHP Stack trace:
[phpunit] PHP 1. {main}() /usr/bin/phpunit:0
[phpunit] PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:29
[phpunit] PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:106
[phpunit] PHP 4. PHPUnit_TextUI_Command->handleArguments() /usr/share/php/PHPUnit/TextUI/Command.php:117
[phpunit] PHP 5. PHPUnit_TextUI_Command->handleBootstrap() /usr/share/php/PHPUnit/TextUI/Command.php:622
[phpunit] PHP 6. PHPUnit_Util_Fileloader::checkAndLoad() /usr/share/php/PHPUnit/TextUI/Command.php:793
[phpunit] PHP 7. PHPUnit_Util_Fileloader::load() /usr/share/php/PHPUnit/Util/Fileloader.php:38
[phpunit] PHP 8. include_once() /usr/share/php/PHPUnit/Util/Fileloader.php:56
[phpunit] PHP Fatal error: require(): Failed opening required '/var/lib/jenkins/workspace/mavajob/app/../vendor/autoload.php' (include_path='.:/usr/share/php') in /var/lib/jenkins/workspace/mavajob/app/autoload.php on line 9
[phpunit] PHP Stack trace:
[phpunit] PHP 1. {main}() /usr/bin/phpunit:0
[phpunit] PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:29
[phpunit] PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:106
[phpunit] PHP 4. PHPUnit_TextUI_Command->handleArguments() /usr/share/php/PHPUnit/TextUI/Command.php:117
[phpunit] PHP 5. PHPUnit_TextUI_Command->handleBootstrap() /usr/share/php/PHPUnit/TextUI/Command.php:622
[phpunit] PHP 6. PHPUnit_Util_Fileloader::checkAndLoad() /usr/share/php/PHPUnit/TextUI/Command.php:793
[phpunit] PHP 7. PHPUnit_Util_Fileloader::load() /usr/share/php/PHPUnit/Util/Fileloader.php:38
[phpunit] PHP 8. include_once() /usr/share/php/PHPUnit/Util/Fileloader.php:56
[phpunit] Result: 255

我按照这些说明http://jenkins-php.org/automation.html 也许有人可以为symfony3提供build.xml和phpunit.xml的工作示例?

1 个答案:

答案 0 :(得分:1)

在我尝试执行PHPUnit之前,我好像忘记在CI服务器上运行composer install

只需为composer添加另一个目标(假设您已经安装了composer):

<target name="composer" description="Installing composer dependencies">
 <exec executable="composer" failonerror="true">
  <arg value="install" />
 </exec>
</target>

并使其成为需要它的其他目标的依赖。例如,对于full-build,您可以在准备之后立即将其放好:

 <target name="full-build"
         depends="prepare,composer,static-analysis,phpunit,phpdox,-check-failure"
         description="Performs static analysis, runs the tests, and generates project documentation"/>