Php 使用Laravel的具有docker映像的Bitbucket管道

Php 使用Laravel的具有docker映像的Bitbucket管道,php,laravel,bitbucket-pipelines,docker-image,Php,Laravel,Bitbucket Pipelines,Docker Image,我想使用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://getcompo

我想使用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
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.
提交并运行测试后,测试失败

我使用下面的配置修改了上述配置,以测试数据库:

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个失败的构建。有人能帮助完成成功的构建吗?

测试数据库或任何其他第三方应用程序应使用集成测试而不是单元测试,如果您试图使用单元测试数据库,请确保测试失败,因为您没有在运行测试之前实现正确的连接,而测试应该仅通过集成测试完成


还要确保在正确的目录中调用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”字符串后,现在构建成功。

如下图所示:

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
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.
echo“你好,世界!”

你能分享一下你从管道中得到的确切错误吗?有一件事你可以肯定地检查一下,尽管它可能不重要,那就是你的文件的缩进。第二,你能发布错误或日志吗?如果我们能够看到发生的确切错误,那么可以更容易地帮助了解问题所在。嗨,亚欧会议,我想执行连续集成(CI)来使用docker映像构建应用程序,但失败了。我没有使用单元测试。在您的代码“vendor/bin/phpunit”中,持续集成的整个要点是构建代码以便在部署之前进行测试,如果您只想在不进行测试的情况下进行部署,那么您必须删除运行单元测试的部分,之后它应该可以正常工作,祝您好运:)