Laravel Quickstart - Basic
Quick Installation
git clone https://github.com/laravel/quickstart-basic quickstart
cd quickstart
composer install
php artisan migrate
php artisan serve
CI Pipeline for TODO application
- The deployment of the application was carried out from Artifactory.
STEPS
- Install Artifactory on the artifactory server
sudo apt-get install gnupg2 -y
wget -qO - https://api.bintray.com/orgs/jfrog/keys/gpg/public.key |sudo apt-key add -
sudo echo "deb https://jfrog.bintray.com/artifactory-debs bionic main" | sudo tee /etc/apt/sources.list.d/jfrog.list
sudo apt update -y
sudo apt install jfrog-artifactory-oss -y
sudo systemctl start artifactory
sudo systemctl enable artifactory
-
On the Jenkins server, Install PHP, its dependencies and Composer tool
sudo yum install -y zip phploc php-{xml,bcmath,bz2,intl,gd,mbstring,mysqlnd,zip}
-
In artifactory ui, create a repository that has the same name as your “target” in your jenkinsfile (under the Artifact deployment stage). In this case, it is php-todo Jenkinsfile
-
Create the necessary database requirements and edit the .env.sample file
-
Update the Jenkins file to include Unit tests step Jenkinsfile
Next, setup code coverage report on the jenkins server.
-
run
php --ini
to see loaded modules and php config files. -
from 1, try to find the xdebug file among the outputs, if its not there an install should be made (sudo yum/apt install php-xdebug)
-
run
php --ini
again and this time the xdebug file should be among the list of files. -
edit the xdebug file in the output (run php --ini | grep xdebug) to locate the file.
To edit, find the commented line (;xdebug.mode = develop) and change it to (xdebug.mode = coverage). The file also says something about passing a global environment variable XDEBUG_MODE to bypass the default one set in the file, so you may use this method also.
- restart php (sudo systemctl restart php-fpm)
-
add the code quality analytics stage to the pipeline and run it
-
Package the artifact and deploy to artifactory server
-
Next, deploy to dev environment and configure sonarqube server (see sonarqube role)
-
Install the sonar plugin on Jenkins UI. Configure sonarqube and Jenkins for quality gates
-
edit the sonar.properties file located in
/var/lib/jenkins/tools/hudson.plugins.sonar.SonarRunnerInstallation/SonarQubeScanner/conf/
#sonar.sourceEncoding=UTF-8
sonar.host.url=http://3.135.221.18:9000 # replace url here
sonar.projectKey=php-todo
#----- Default source code encoding
sonar.sourceEncoding=UTF-8
sonar.php.exclusions=**/vendor/**
sonar.php.coverage.reportPaths=build/logs/clover.xml
sonar.php.tests.reportPath=build/logs/junit.xml
-
Update the jenkins pipeline to include sonarqube scanning stage
-
Add conditional deployment to higher environment stages in the jenkins pipeline
-
Add 2 more servers to be used as Jenkins slave. Configure Jenkins to run its pipeline jobs randomly on any available slave nodes.
- Under the managed jenkins, add nodes. In the node configuration section, provide necessary details.
- Also provide the private key of the node (jenkins will use it to connect). Make sure the java-jdk is installed on the slave(s).
- Configure webhook between Jenkins and Github to automatically run the pipeline when there is a code push.
- Install multibranch scan webhook trigger in manage plugins
- Edit the scan repository triggers section of the multibranch pipeline. Also check the info and copy the syntax for the webhook( JENKINS_URL/multibranch-webhook-trigger/invoke?token=[Trigger token]). Replace accordingly (e.g; http://x.x.x.x:8080/multibranch-webhook-trigger/invoke?token=ci-jaasp-token-value)
- Deploy application to remaining environments