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

Can't accomplish build with Jenkins, Symfony3 and PHPUnit 5.3

尝试学习 CI,我遇到了以下问题: 命令行中的 Ant 给出 'BUILD SUCCESSFUL' 消息。 当我将代码推送到 AWS 上的 GitHub 和 运行 Jenkins 时,除 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 的工作示例?

在我看来,您似乎在尝试执行 PHPUnit 之前忘记了 运行 composer install 在 CI 服务器上。

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

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

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

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