2017-02-16 22 views
0

我用PHPUnit和laravel創建了一些測試。測試在本地運行成功,但作爲gitlab ci作業存在錯誤。我如何調試失敗的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

好的,解決方案非常簡單...我不會刪除問題。這裏是解決方案:

你必須添加一個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

相關問題