Merging and Deploying dev-branch and master-branch Using Jenkins and Docker Container
Job1 :- If a Developer pushes their code to dev1 branch then Jenkins will fetch from dev1 and deploy on dev1_docker environment.
Job2 :- If Developer push to master branch then Jenkins will fetch from master and deploy on master_docker environment.
Job3 :- Jenkins will check (test) for the website running in the dev1_docker environment. If it is running fine then Jenkins will merge the dev1 branch to master branch and trigger JOB#2.
Let’s get started …
The prerequisite for this task is to install Docker and Jenkins on your Pc for Docker installation you can refer article link given below :
Installing Docker in Linux…
For installing docker you first need to setup Yum repo. Lets get started..
First adding code to git we will create a repo inside git which has two branches- dev and master we will push index.html inside both branches.
https://github.com/parinati789/Jenkins_Task2.git ← Refer to it for code…
We are using ngrok to make a Tunnel between public and private IP.
It's time to create our JOB 1, let’s begun.
Job 1 will push the code from Github to a container inside docker.
New Item → Give your job name “job1” → Select “Freestyle Project” → Ok
provide git repo URL in Source Code Management
Note:- Branch Specifier should be “*/dev”
Add Webhook inside GitHub:
let’s Build job1
Confirm the Docker container is running or not
Hurry, Job 1 was a success now let's move further.
It’s time to create our JOB 2, let’s begun.
Job 2 will push the code from Github to a container inside docker.
Now let’s build job2
Job 2 was also a success now let’s move further.
It’s time to create our JOB 3, let’s begun.
Job 3 will be used to merge both dev and master branches.
Job 3 was also a success