Few months ago, I was trying to setup a pipeline for a Laravel project that I was working on, but I encountered some issues, I wasn't able to get an article that explains the process to a beginner, the Whys and Hows you know, but I was able to get it done. Setting up a Pipeline for a PHP or a Laravel project is easier than you might think, the prerequisite for this article are; Docker (Install docker on your computer, we'd be using a Jenkins image and setting up Laravel and PHP in the container).
So far we have setup Jenkins and PHP on the same image, this means we can run PHP commands right from Jenkins Pipeline Console, but PHP is not enough, we need to install Composer too.
Everything is setup now, run docker image build -t jenkins-laravel., we can now run PHP and composer commands right inside Jenkins Pipeline Console and this is all we need to setup Laravel.
pipeline { agent any stages { stage('Build') { steps { git 'https://github.com/Kennibravo/jenkins-laravel.git' sh 'composer install' sh 'cp.env.example.env' sh 'php artisan key:generate' }} stage('Test') { steps { sh './vendor/bin/phpunit' }} }} #quick-explanation-on-what-the-codes-actually-does Quick explanation on what the codes actually does stages { stage('Build') { steps { git 'https://github.com/Kennibravo/jenkins-laravel.git' sh 'composer install' sh 'cp.env.example.env' sh 'php artisan key:generate' }} stage('Test') { steps { sh './vendor/bin/phpunit' }} }