Laravel 11 Bitbucket 管道配置

问题描述 投票:0回答:1

在最近的 Laravel 11 升级之前,我们在 Bitbucket 中有一个有效的构建管道,但现在它无法找到连接到数据库的 mysql 驱动程序。 这是运行迁移/测试时的错误:

In Connection.php line 825:                                                                           
  could not find driver (Connection: mysql, SQL: select exists (select 1 from  
   information_schema.tables where table_schema = 'homestead' and table_name   
  = 'migrations' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED')) as `ex  
  ists`)                                                                       
                                                                          
In Connector.php line 66:              
  could not find driver

这是我们的工作(L9-10)bitbucket-pipelines.yml:

image: php:8.2-fpm

definitions:
  services:
    mysql:
      image: mysql:8.0
      environment:
        MYSQL_DATABASE: 'homestead'
        MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
        MYSQL_USER: 'homestead'
        MYSQL_PASSWORD: 'secret'
  steps:
    - step: &install-dependencies
        name: Setup
        caches:
          - composer
          - node
        script:
          - docker-php-ext-install pcntl
          - apt-get update && apt-get install -qy git curl unzip
          - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
          - composer install --no-progress --no-scripts
          - curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
          - apt-get install -y nodejs
          - npm i --no-progress
          - npm run build
        artifacts:
          - vendor/**
          - node_modules/**
          - public/**
  .scripts:
    - &setup-tests |
        apt-get update && apt-get install -qy libmcrypt-dev default-mysql-client
        echo "memory_limit = 256M" > $PHP_INI_DIR/conf.d/php-memory-limits.ini
        cp .env.pipelines .env
        php artisan key:generate
        php artisan storage:link

pipelines:
  # default pipeline
  branches:
    '{develop,staging,master}':
      - step: *install-dependencies
      - parallel:
        - step:
            name: Unit
            script:
              - *setup-tests
              - php artisan test tests/Unit
            services:
              - mysql
        - step:
            name: Feature
            script:
              - *setup-tests
              - php artisan test tests/Feature
            services:
              - mysql

我能够使用 mysql 驱动程序在本地运行测试,因此图像中似乎缺少一个扩展。

laravel bitbucket-pipelines laravel-11
1个回答
0
投票

通过将

docker-php-ext-install pdo_mysql
添加到
setup-tests
脚本来修复。

© www.soinside.com 2019 - 2024. All rights reserved.