I want to create a ci cd gitlab pipeline for Laravel project and steps of deployment contain some commands like below:
-composer install;
-PHP artisan migrate;
-PHP artisan optimize :clear;
this is my pipe line code
image:
name: composer:latest
before_script:
- echo "Before script"
services:
- mysql:latest
- redis:latest
building:
stage: build
script:
- composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-scripts
- php artisan migrate --force
- php artisan optimize:clear
testing:
stage: test
script:
- php ./vendor/bin/phpunit
deploying:
stage: deploy
script:
- echo "Deployed"
the first command execute very well but in second command I get this error and i do not know what happen in third command!! :
78 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
$ php artisan migrate --force
Illuminate\Database\QueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:742
738▕ // If an exception occurs when attempting to run a query, we'll format the error
739▕ // message to include the bindings with SQL, which will make this exception a
740▕ // lot more helpful to the developer instead of just the database's errors.
741▕ catch (Exception $e) {
➜ 742▕ throw new QueryException(
743▕ $query, $this->prepareBindings($bindings), $e
744▕ );
745▕ }
746▕ }
+33 vendor frames
34 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
Cleaning up project directory and file based variables
00:02
ERROR: Job failed: exit code 1