AUTOMATION OF WEB SERVER
WHAT IS AUTOMATION
Automation is the technology by which a process or procedure is performed with minimal human assistance. Automation or automatic control is the use of various control systems for operating equipment such as machinery, processes in factories, boilers, and heat treating ovens, switching on telephone networks, steering, and stabilization of ships, aircraft, and other applications and vehicles with minimal or reduced human intervention. Today I’m explaining automation through CONTINOUS INTEGRATION
Continuous Integration
Continuous Integration is a software development practice where developers frequently integrate their work with the project’s integration branch and create a build.
Integration is the act of submitting your personal work (modified code) to the common work area (the potential software solution). This is technically done by merging your personal work (personal branch) with the common work area (Integration branch). Continuous Integration is necessary to bring out issues that are encountered during the integration as early as possible.
This can be understood from the following diagram, which depicts various issues encountered during a software development lifecycle. I have considered a practical scenario wherein I have chosen the Scrum development model, and for the sake of simplicity, all the meeting phases are excluded. Out of all the issues depicted in the following diagram, the following ones are detected early when Continuous Integration is in place:
- Build failure (the one before integration)
- Integration issues
- Build failure (the one after integration)
In the event of the preceding issues, the developer has to modify the code in order to fix it. A build failure can occur either due to an improper code or due to a human error while doing a build (assuming that the tasks are done manually). An integration issue can occur if the developers do not rebase their local copy of code frequently with the code on the Integration branch.
An example to understand Continuous Integration
First of all, do the following steps to push your code into GitHub.
mkdir web_deployment
cd web_deployment
git init
git remote add origin <repolink>
Then next we will configure the post-commit hook.
touch ./git/hooks/post-commit
vim ./git/hooks/post-commit
Now add the following lines to o the post-commit to push the code whenever the developer commits the code.
#!/bin/bash
git push
Job1
Developer push to master branch then Jenkins will fetch from master and deploy on the master-docker environment Same as dev-branch we will do it with the master branch also. We will clone the code.
JOB 2
Developer push to master branch then Jenkins will fetch from master and deploy on the master-docker environment.
git checkout -b dev
echo “FIRST-BRANCH” >> index.html
git add
git commit -m “second”
git push origin dev
JOB 3
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 the master branch and trigger JOB1.