Automating the launch of Testing and Deployment Environment using jenkins- docker-github.

Amardeep Kumar
5 min readNov 3, 2020


! TASK-1 !


If Developer push to “dev” branch then Jenkins will fetch from “dev” and deploy on the “dev-docker” environment.


If Developer push to “master” branch then Jenkins will fetch from “master” and deploy on the master-docker” environment.
both “dev-docker” and “master-docker” environments are on different docker containers.


Manually the QA team will check (test) for the website running in the “dev-docker” environment. If it is running fine then Jenkins will merge the “dev” branch to “master” branch and trigger #job2

Task Description

This Project is based on the integration of Github with Docker and Jenkins .

Github : GitHub, Inc. is a United States-based global company that provides hosting for software development version control using Git. It offers the distributed version control and Source Code Management (SCM) functionality of Git, plus its own features.

Docker : Docker is a set of platform as a service (PaaS) products that uses OS-level virtualization to deliver software in packages called containers. The software that hosts the containers is called Docker Engine.

Jenkins : Jenkins is a free and open-source automation server. It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery.

First of all install git which is the Decentralised version control system (DVCS).

Make a local git repository name as “git init” repository also known as (workspace+version)

Now initiate the git in the workspace by “git init “ command and make an HTML file for the website.

Create a GitHub repository ( centralized version control system) where we can upload our website content.

  • Push this code to dev branch .
  • This code is pushed to the dev branch .
  • To create a new branch and switch to that branch , we can also use this command

git checkout -b <branch_name>”

Now we create #job 1 In this job if developer push the code to dev branch then Jenkins will fetch from dev and deploy on dev docker environment

Set the build triggers Poll SCM

Execute Shell code

sudo cp -v -r -f * /dev

if sudo docker ps | grep testos


echo “already launch”


sudo docker run -dit -p 8082:80 -v /dev:/usr/local/apache2/htdocs/ — name testos httpd


1st job is created.

Now job2, In this job developer push to master branch then Jenkins will fetch from master and deploy on the master-docker environment (production environment).

Execute Shell code

sudo cp -v -r -f * /prod

if sudo docker ps | grep prodos


echo “already launch”


sudo docker run -dit -p 8085:80 -v /dev:/usr/local/apache2/htdocs/ — name prodos httpd


After completion of #job 2 now we can create #job 3

In this job QA team will manually test the website running fine or not in the testing environment.

If the website running fine then #job 3 will merge the dev branch to master branch and trigger the #job 2.

All the jobs are created

Now as soon as a developer commits to dev branch, job1 will runs. This will first update the Github and then copy the changed code and host it in docker for testing.

Manually check the website in testing environment.

If the job 2 run successfully we can see our website

After QA team check the website manually, if it is running well then job 3 will run and dev branch merge with master branch. Job 3 build the job 2 after merge successfully.

after completion of job 2, we can see our website is updated.

Finally, let us create a tunnel so that our client can see the website. To create a tunnel we will use ngrok.

This is the updated website. Our client can see this from the anywhere world.

!!!Thank You!!!



Amardeep Kumar