首页 > 解决方案 > 简单的作曲家缓存因 bitbucket 管道而失败

问题描述

我正在尝试学习管道,并且我已经建立了一个简单的 2 个步骤。
1. 设置作曲家并缓存它
2. 构建和测试

请注意,我正在构建一个子文件夹

我没有收到任何错误,但它失败了。这就是构建拆解必须说的:

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: 
 name: php:7.1.1
 run-as-user: 1

pipelines:
  default:
    - step:
        name: setup composer
        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
    - step:
        name: build and test
        caches:
           - composer
        script:
          - composer global require hirak/prestissimo
          - composer install -d cms/content/
          - vendor/bin/phpunit

definitions:
  caches:
    composer: cms/content/

标签: composer-phpbitbucket-pipelines

解决方案


Composer 缓存只缓存使用 下载的依赖项composer install,下载的 Composer 将始终被删除以进行下一步。解决此问题的最佳方法是将作曲家操作放在第一步中,保存工件(vendor目录)以供下一步并在该步骤中测试您的应用程序。

这看起来像这样:

image: 
 name: php:7.1.1
 run-as-user: 1

pipelines:
  default:
    - step:
        name: Build
        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 global require hirak/prestissimo
          - composer install -d cms/content/
        artifacts:
          - cms/content/vendor/**
    - step:
        name: Test
        script:
          - vendor/bin/phpunit

definitions:
  caches:
    composer: cms/content/

注意:我也认为你vendor/bin/phpunit应该是cms/content/vendor/bin/phpunit


推荐阅读