You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I have an issue running tests that requires DB connection. First part where pipeline is built works fine. Even `php artisan migrate` goes through.
But Test step fails when test tries to add data to database with: `could not find driver (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')` . I tried changing host to 127.0.0.1 or mysql but it doesn't change anything.
Most of my .yml file is based on example I found in bitbucket documentation so I am nt sure why its not working.
Here is my bitbucket-pipelines.yml file:
# Template PHP Build
# This template allows you to validate your PHP application.
# The workflow allows running tests and code linting on the default branch.
image: php:8.2-fpm
pipelines:
default:
- step:
script:
- apt-get update && apt-get install -y unzip zip
- apt-get update && apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev
- apt-get update && apt-get install -qy git curl libmcrypt-dev default-mysql-client
- docker-php-ext-install pdo pdo_mysql
- yes | pecl install mcrypt-1.0.6
- curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- COMPOSER_ALLOW_SUPERUSER=1 composer install
- cp .env.pipeline .env
- php artisan migrate --force
artifacts:
- storage/**
- vendor/**
- public/**
- .env
caches:
- composer
services:
- mysql
- parallel:
- step:
name: Tests
script:
- php artisan test
definitions:
services:
mysql:
image: mysql:5.7
environment:
MYSQL_DATABASE: 'homestead'
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
MYSQL_USER: 'homestead'
MYSQL_PASSWORD: 'secret'
And here is .env:
APP_ENV=local
APP_KEY=ThisIsThe32CharacterKeySecureKey
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
Hi Artis and welcome to the community!
At the moment there is no mechanism for a Pipelines build to wait for service startup (we have a request in our issue tracker for the build to wait until all services are ready: https://jira.atlassian.com/browse/BCLOUD-15244). If the command that fails is the first one in that step, the mysql service may not be ready yet. You can try adding a wait command as the first command of the build (e.g. for 5, 10 or 30 seconds) and see if that helps.
Please also ensure that:
You can also try debugging the build locally with Docker (using the same images you have in your yml file) to ensure that the configuration in your code is correct and the build succeeds locally with Docker:
In step 3 of the guide, there is a section on how to test with build services.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.