我如何调试失败的ci构建?

时间:2017-02-16 17:15:57

标签: php laravel continuous-integration gitlab-ci

我用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中调试错误的最佳做法是什么?

1 个答案:

答案 0 :(得分:1)

好的,解决方案非常简单......我不删除这个问题。这是解决方案:

您必须在作业中添加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的管道部分下载工件:

Gitlab Artifacts download

相关问题