Merging of Git Branches Using Jenkins Job
In this I will explain how to integrate/merge Git branches using Jenkins.
TASK DESCRIPTION →
JOB 1:-
If Developer push to dev branch then Jenkins will fetch from dev and deploy on dev-docker environment.
JOB 2:-
If Developer push to master branch then Jenkins will fetch from master and deploy on master-docke environment.
both dev-docker and master-docker environment are on different docker containers.
JOB 3:-
Manually the QA team will check (test) for the website running in dev-docker environment. If it is running fine then Jenkins will merge the dev branch to master branch and trigger #JOB 2
TASK SOLUTION →
Solution For Job 1 (Dev Branch)-
I created a code in dev branch and push it on GitHub . Then I fetch this code in Jenkins with GitHub plugin
I used the execute shell and run these commands
sudo cp * /root/task1/dev
if sudo docker ps | grep job1_dev
then
echo “already running in docker”
else
sudo docker run -dit -v /root/task1/dev:/var/www/html/ — name job1_dev vimal13/apache-webserver-php
fi
Solution For Job 2 (Master Branch)-
I develop program in master branch in put it on GitHub. These files are fetch by jenkins . This job will build after job 1.
I used the execute the shell and run these commands-
sudo cp * /root/task1/master
if sudo docker ps | grep job2_master
then
echo “it is running go and test it”
else
sudo docker run -dit -v /root/task1/master:/var/www/html/ — name job2_master vimal13/apache-webserver-php
fi
Solution For Job 3(Merging of Dev and Master Branch)-
For job 3, I merged the JOB 1 and JOB 2.
HERE is the complete build pipeline of All the jobs where JOB 2 triggered by JOB 1and JOB 3 triggered by JOB 2.
JOB 1 → JOB 2 → JOB 3 →
So whole task1 is completed now
I hope you like it , if any understanding or error occur then write your comment below .
Thank you for read this BLOG .
GITHUB URL → https://github.com/shubhamkhandelwal523/mlopstask1.git
LinkedIN URL → https://www.linkedin.com/in/shubham-khandelwal-a04613144/