簡體   English   中英

Bitbucket 管道與 docker 圖像使用 Laravel

[英]Bitbucket pipelines with docker image using Laravel

我想使用 Bitbucket 管道執行持續集成來構建我的項目。 我首先使用了帶有默認配置的 bitbucket-pipeline.yml 文件,如下所示:

image: php:7.1.29
pipelines:
default:


- step:
    caches:
      - composer
    script:
      - apt-get update && apt-get install -y unzip
      - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
      - composer install
      - vendor/bin/phpunit

提交並運行測試后,它失敗了。

我用下面的配置修改了上面的配置來測試數據庫:

image: phpunit/phpunit:6.5.3

pipelines:
default:
- step:
  caches:
  - composer
  script:
  - apk add --no-cache php7-gd php7-xmlwriter
  - php -r "file_exists('.env') || copy('.env.testing', '.env');"
  - composer install
  - php artisan key:generate
  - php artisan migrate --seed
  - vendor/bin/phpunitenter 

但是當我再次嘗試運行它時,它失敗了。 我現在有 8 個失敗的構建。 任何人都可以幫助完成成功的構建嗎?

測試數據庫或任何其他第 3 方應用程序應該使用集成測試而不是單元測試來完成,如果您嘗試使用單元測試來測試數據庫,它肯定會失敗,因為您在運行測試之前沒有實現正確的連接應該只通過集成測試來完成。

還要確保在正確的目錄中調用 bin/phpunit,你應該 cd 到 laravel 的主測試目錄,然后執行../vendor/bin/phpunit Unit

您絕對可以檢查的一件事是文件的縮進,盡管它可能並不重要。 其次,您可以發布錯誤或日志嗎? 如果我們能夠看到發生的確切錯誤,幫助查看問題所在會更容易。

這是構建失敗的地方

問題是作曲家。 composer 安裝成功但運行失敗,如下圖所示:

+ curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin -- 
filename=composer
All settings correct for using Composer
Downloading...
Composer (version 1.9.0) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

+ composer install
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages. 

Problem 1
- This package requires php ^7.2 but your PHP version (7.1.29) does not satisfy that 
requirement.

Problem 2
- Installation request for moontoast/math 1.1.2 -> satisfiable by 
moontoast/math[1.1.2].
- moontoast/math 1.1.2 requires ext-bcmath * -> the requested PHP extension bcmath is 
missing from your system.

Problem 3
- Installation request for sebastian/type 1.1.3 -> satisfiable by 
sebastian/type[1.1.3].
- sebastian/type 1.1.3 requires php ^7.2 -> your PHP version (7.1.29) does not 
satisfy that requirement.

Problem 4
- doctrine/lexer 1.1.0 requires php ^7.2 -> your PHP version (7.1.29) does not 
satisfy that requirement.
- doctrine/lexer 1.1.0 requires php ^7.2 -> your PHP version (7.1.29) does not 
satisfy that requirement.
- Installation request for doctrine/lexer 1.1.0 -> satisfiable by 
doctrine/lexer[1.1.0].

在此處輸入圖像描述

現在,當刪除我以前的代碼並測試“Hello word”字符串時,構建成功。

如下所示:

echo "Hello world!"
<1s 
Build teardown
<1s
Searching for test report files in directories named [test-results, failsafe-reports, 
test-reports, surefire-reports] down to a depth of 4
Finished scanning for test reports. Found 0 test report files.
Merged test suites, total number tests is 0, with 0 failures and 0 errors.

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM