我如何调试失败的 ci 构建?
How can i debug a failed ci build?
我用 PHPUnit 和 laravel 创建了一些测试。测试 运行 在本地成功,但作为 gitlab ci 作业出现错误。
这是 ci 日志:
There was 1 failure:
1) Tests\Feature\AuthTest::testAuthLoggedInIsAdmin
Expected status code 200 but received 500.
Failed asserting that false is true.
/builds/XXX/webproject/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:55
/builds/XX/webproject/tests/Feature/AuthTest.php:53
为了更好地调试和找到解决方案,我需要来自项目的错误跟踪或来自网络服务器的 error.log
。
在 ci 中调试错误的最佳做法是什么?
ok,解决方法很简单……我就不删题了。这是解决方案:
您必须在作业中添加 artifact
。您可以设置工件,只有在失败时才会创建工件。如果构建失败,孔项目将转储到一个单独的位置。现在您可以浏览转储中的每个文件。
.gitlab-ci.yml
stages:
- test
- deploy
php-7.0:
stage: test
type: test
services:
- mysql:latest
image: tetraweb/php:7.0
script:
- bash .gitlab-ci.sh
- php vendor/bin/phpunit --coverage-text --colors=never
artifacts:
when: on_failure
name: "${CI_BUILD_STAGE}_${CI_BUILD_REF_NAME}_FAILED"
paths:
- "."
untracked: false
expire_in: 1 day
deploy:
stage: deploy
# etc...
Here 是关于工件的更多信息。
您可以在 gitlab 的管道部分下载工件:
我用 PHPUnit 和 laravel 创建了一些测试。测试 运行 在本地成功,但作为 gitlab ci 作业出现错误。
这是 ci 日志:
There was 1 failure:
1) Tests\Feature\AuthTest::testAuthLoggedInIsAdmin
Expected status code 200 but received 500.
Failed asserting that false is true.
/builds/XXX/webproject/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestResponse.php:55
/builds/XX/webproject/tests/Feature/AuthTest.php:53
为了更好地调试和找到解决方案,我需要来自项目的错误跟踪或来自网络服务器的 error.log
。
在 ci 中调试错误的最佳做法是什么?
ok,解决方法很简单……我就不删题了。这是解决方案:
您必须在作业中添加 artifact
。您可以设置工件,只有在失败时才会创建工件。如果构建失败,孔项目将转储到一个单独的位置。现在您可以浏览转储中的每个文件。
.gitlab-ci.yml
stages:
- test
- deploy
php-7.0:
stage: test
type: test
services:
- mysql:latest
image: tetraweb/php:7.0
script:
- bash .gitlab-ci.sh
- php vendor/bin/phpunit --coverage-text --colors=never
artifacts:
when: on_failure
name: "${CI_BUILD_STAGE}_${CI_BUILD_REF_NAME}_FAILED"
paths:
- "."
untracked: false
expire_in: 1 day
deploy:
stage: deploy
# etc...
Here 是关于工件的更多信息。
您可以在 gitlab 的管道部分下载工件: