Integration of Git/GitHub, Docker and Jenkins

Integration of Git/GitHub, Docker and Jenkins



This project is based on continuous development, continuous integration and continuous deployment. Using DevOps tools, a completely automated setup has been made in which the developer only needs to commit the source code and the changes will get displayed on website running on a web server.

Workflow of task

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-docker 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.

Step -1 Create a git local repositiory

  1. Create a folder and initialize it
  2. Create a file
  3. Add file to staging area
  4. Add file to commit area
  5. Now add remote and connect to github repo
  6. Finally push file to github

For above process ,we use the below commands.

git init
notepad index.html
git add index.html
git commit index.html -m "1st master commit"
git remote add origin https://github.com/Ds123-wq/task.git
git push -u origin master
No alt text provided for this image
No alt text provided for this image

Now we can create a hook which is present in the folder .git/hooks/. You can see many files in there. We create a file "post-commit".This file is used to trigger just after commit.So we use push command inside it.So when commit success,it automatically push the code to github by this trigger.

No alt text provided for this image


So when commit is done ,it push the code to github in master branch.

Create a new branch for other developer "dev1" .In this branch ,developer write code and add it to staging area ,then commit to commit area.As soon as developer commit,it uses post-commit file and upload code to github in dev1 branch.

git checkout -b dev1
notepad index.html 
git add index.html 
git commit index.html -m "1st dev1 commit"


Step-2 Create job1 of jenkins

This job is used run when Developer push to dev branch then Jenkins will fetch from dev and deploy on dev-docker environment.

No alt text provided for this image

In this job ,we provide the GitHub Repository Link and Also, specify the branch to be dev1 to fetch those files only.

No alt text provided for this image

In Build trigger ,use Poll SCM which runs after every minutes .After every minute,jenkins goto github and if new code come up ,then download the new code.

No alt text provided for this image
No alt text provided for this image

In execute shell, run the above code .This code first copy the new dev1 branch code to /root/testing directory and check testing container is running or not .If not,then it start again it. After job-1 done ,we can verify by base os ip and given port no.90.We paste 192.68.43.130:90 in chrome we see code of dev1 branch.

No alt text provided for this image

Here we see 1st commit master code and dev1 branch code .Because dev1 branch is created after 1st commit of master branch.When feature branch is created ,it will also access all previous code of master branch .

Step-3 Create job-2 of jenkins

This job is used to is check if Developer push code by master branch ,then Jenkins will fetch code of master branch from github and deploy on master-docker environment.

No alt text provided for this image


In this job ,we provide the GitHub Repository Link and Also, specify the branch to be master to fetch those files only.

No alt text provided for this image

In Build trigger ,use Poll SCM which runs after every minutes .After every minute,jenkins goto github and if new code come up ,then download the new code.And It aslo trigger by QA team job-3.

No alt text provided for this image


No alt text provided for this image

In execute shell, run the above code .This code first copy the master branch code to /root/production directory and check production container is running or not .If not,then it start again it. After job-2 done ,we can verify by base os ip and given port no.91.We paste 192.68.43.130:91 in chrome we see code of master branch.

No alt text provided for this image

Step-4 Create job-3 of jenkins

Now for the next job the objective is 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.

We will assume that the QA team has approved the changes to be merged and therefore, this job will merge both the branches.

No alt text provided for this image

In this job ,we provide the GitHub Repository Link and Also, specify the branch to be master to fetch those files only.

No alt text provided for this image

In SCM ,we use additional behaviour "merge before build" to merge both branches

No alt text provided for this image

After successful merge of branches ,post-build Action is used to upload the code to github in master branch.

No alt text provided for this image

After job-3 done ,it triggers to job-2 and deploy the code in production environment .We can verify by base os ip and given port no.91.We paste 192.68.43.130:91 in chrome we see code of master branch and dev1 branch.

No alt text provided for this image

Thus, we have successfully automated the process of SCM using Integration of Git/GIitHub with Jenkins and Docker.

Thank you,


要查看或添加评论,请登录

Deepak Sharma的更多文章

  • Jenkins Dynamic Provisioning

    Jenkins Dynamic Provisioning

    Objectives In this article , We will see how we can create dynamic slave on the fly when job come and attach to the…

    1 条评论
  • OSPF Routing Protocol using Dijkstra Algorithm

    OSPF Routing Protocol using Dijkstra Algorithm

    Objectives:- In this article, We will learn about Dijkstra Algorithm and Open Short Path First(OSPF) Routing Protocol .…

    1 条评论
  • MongoDB Case study: Forbes

    MongoDB Case study: Forbes

    Objective In this article , we see how MongoDB Cloud Migration Helps World's Biggest Media Brand Continue To Set…

  • Vehicle’s Number Plate Detection using CNN model using python and Flask API…

    Vehicle’s Number Plate Detection using CNN model using python and Flask API…

    In this article, I am going to show you how you can create CNN Model or Deep Learning Model for Vehicle’s Number Plate…

    8 条评论
  • K-means Clustering and its real use cases in security domain

    K-means Clustering and its real use cases in security domain

    Objectives:- In this article, we will see about the Kmean algorithm and how Kmean algorithm helps in security domain to…

  • JavaScript:- Industry Use-cases

    JavaScript:- Industry Use-cases

    Objective In this article , we will learn about the JavaScript and the use-cases of JavaScript. How Industries utilizes…

  • Confusion Matrix and Cyber Security

    Confusion Matrix and Cyber Security

    Objectives:- In this article , we will see about confusion matrix and the use of confusion matrix . Also we see how…

  • Self-Reflection of MongoDB-Workshop

    Self-Reflection of MongoDB-Workshop

    # Day1 (1st May 2021) ?? Introduction of the file system? ??The data we will stored in file and that file we basically…

  • OpenShift case study:- Cisco

    OpenShift case study:- Cisco

    Cisco’s success depends on its ability to quickly deliver innovative IT products and solutions to customers. Delays can…

  • Industry Use cases of Jenkins:- Prepl

    Industry Use cases of Jenkins:- Prepl

    In 2021, When industries are running towards automation, adopting different DevOps tools to solve their industrial…

社区洞察

其他会员也浏览了