🔰What is meant by DevOps Automation ??
Automation is the process which helps developer to execute the entire program automatically as well as it keep on checking the updated code on SCM tool like github. It is possible with the help of DevOps tools like Jenkins.
🔰What is meant by Docker??
Docker is a tool which automates the containerization. we can install more than one operating system on docker with in a second without authentication .
🔰What is meant by github ??
Github is the SCM tool i.e. Source Code Management . The developer write the code on github and when developer provide github link to Jenkins then Jenkins automatically execute the code for developer and also Jenkins keep on updating the changing code on github.
😍Now lets see how to integrate Jenkins with docker and github !!!
📌Here we are going to create 3 jobs as following:
💢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.
First of all, we are assuming that Docker, Git, and Jenkins with the Git Plugin are installed in the system.
Now for github settings
📌step1 : go to github
📌step2 : create a new repostory “Github-Jenkins-Docker_IntegrationProject”
📌step3 : create a master branch in master branch create index.html file , inside this file type : this is from master branch and then commit it .
📌step4 : create one more branch i.e dev1 branch also create index.html file , inside this file type: this is from dev1 branch.
Here our github is ready to integrate…
Let’s configure the Jenkins job and integrate it with docker
Job1 :- If a Developer pushes their code to dev1 branch then Jenkins will fetch from dev1 and deploy on dev1_docker environment.
3.1. Task-1 : Automatic Code Download
For now, we have to create new Jobs for downloading the latest codes from both the branches of Github separately, to the Server system, for being deployed on the Web-server.
For creating the Job for downloading codes from the master branch:
📌Step 1 :- Provide github link to Jenkins.
📌Step 2 : Set build triggers.
📌Step 3 : set build environment.
Till now, we have successfully downloaded the codes from both the branches of GitHub to our Server System automatically.
3.2. Task-2: Automatically Starting the Docker containers
Next, we create another Job for starting the docker containers.
📌Step 1 : Provide github link to Jenkins.
📌Step 2 : Set build trigger .
📌Step 3 : Set build environment .
Task-3: Merging the
dev1 branch with
master by QAT
Finally, this is the task of the Quality Assurance Team. When the team certifies that the dev1 branch is working fine, they can merge it with the master branch using Remote Build Triggers.
To set up the Trigger we are going to use Jenkins to do the automation:
📌Step 1: Provide github link to Jenkins.
📌Step 2 : Set build trigger for automation.
📌Step 3: Set post build actions.
Thus, the Job has been setup. To Trigger the Build, the QAT would run the following command:
curl --user "<username>:<password>" JENKINS_URL/job/Mergetest/build?token=TOKEN_NAME
So, after merging, the Job is again fired, so that the updated code can be downloaded in the Server system to run in the web-server.
And we reached the end of the solution!!!😃✌