Tuesday, 25 April 2017

Magento Framework CI-CD

Magento CI-CD


Written By: Amol Khanorkar In this blog we will see how to achieve CI & CD for Magento Framework.


  1. Create git repository and Push code on it.


git@github.com:akk/magento-demo.git




     2.  Create Build Job on Jenkins


Create 1st freestyle new job on Jenkins for building and archiving code.


Add git repository url in Source code management section like below.




In Build section, select Post build trigger job to archiving the code to prepare it for deploying in another 2nd Magento-Deploy project.




Enter, value “ ** ” to archive entire code structure on server like above image.


Now, click on build now button on Project dashboard and it will starts fetching code from git repository and the archive on Jenkins server at specific path.



Path : /var/lib/jenkins/jobs/Magento-Build/builds/


3) Create 2nd project to Deploy code on target server.
Select freestyle project, it will deploy code on target server after previous build get successfully
executed.


In above image, we configured build trigger as up-stream for this job. In which it will start executing once the “Magento-Build” job get finished successfully.


After that in build section, we’ll setup one shell script which create multiple directories like
“shared, releases and current(by symlink)” which maintains code versioning for each deployment.


Script
date=`date +%d%m%Y%H%M`

mkdir -p /var/www/magento_demo/releases/${date}
#mkdir /var/www/magento_demo/shared
cp -rf ${JENKINS_HOME}/jobs/Magento-Build/lastStable/archive/* /var/www/magento_demo/releases/${date}/.

#unlink /var/www/magento_demo/current

ln -sf /var/www/magento_demo/releases/${date}  /var/www/magento_demo/current


This is the basic script which we’ll customize according to the application code requirement.
After that, click on build now button on project dashboard and it will start executing the job on jenkins server.

Below is the code directory structure on server after deployment of application.






current- It has whole source code. Created as symlink from latest release and shared directory.
releases- It contains all the deployed releases according to time stamp.
shared- It has static files and directories which should not be change at the time of deployment. Like, conf files, media/images and user defined data.




1 comment:

  1. Thanks for the instructions the guys are very grateful. I do not particularly like the magento system, I like the wordpress platform, it's probably due to the fact that on wordpress, I have much more work experience. At work, I had to close the project on magento websites, so I had to work, I used ready templates to speed up my work

    ReplyDelete

Amazon EKS - Kubernetes on AWS

By Komal Devgaonkar Amazon Elastic Container Service for Kubernetes (Amazon EKS), which is highly available and scalable AWS service....