douze1332 2017-02-16 17:15
浏览 25
已采纳

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

i created some tests with PHPUnit and laravel. The tests are running locally successful, but as a gitlab ci job there is an error.

Here is the ci log:

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

For the better debug and finding a solution i need the error trace from the project or the error.log from the webserver.

What is the best practise to debug errors in the ci?

  • 写回答

1条回答 默认 最新

  • dstbtam8732 2017-02-16 17:33
    关注

    ok, the solution is very simple... i don't delete the question. Here is the solution:

    You have to add an artifact to the job. You can set the artifact, that only on failures the artifact is created. If there is an failure on the build, the hole project is dumped to a seperated location. Now you can browse each files on the dump.

    .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 are more informations about artifacts.

    You can download the artifacts in the pipelines section in gitlab:

    Gitlab Artifacts download

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路