Getting Started with CI/CD

Poojan Mehta
5 min readMay 7, 2020

→WHAT IS THE PROBLEM STATEMENT?

TOOLS USED — GIT, JENKINS, DOCKER.

→Jenkins plays 3 jobs in this system

job-1) Jenkins will keep on monitoring and keep on deploying out the site on a TESTING server

job-2)Jenkins will keep on monitoring and keep on deploying out the site on the PRODUCTION server

job-3)It will run this job only when it is triggered by the testing team and it will merge branched and run job 2 and finally destroy the testing server!

SYSTEM CONFIGURATION/REQUIREMENTS-

→Base os Windows and virtual os Redhat Linux

→Jenkins installed in your RedHat system (including GitHub plugin)

→Docker installed with https configuration

→Git installed in Windows and Redhat os

→Ngrok (optional)

DETAILED DESCRIPTION ABOUT THE WHOLE PROCESS-

→ Starting with GIT

| → Create a git repository on GitHub and clone it into your local system

| →Create files in the local system and push them to GitHub

COMMANDS USED-

1) git clone <repo. URL> — to clone the repository to your local system

2) notepad file1.txt — to create a file for our use

3) git add file1.txt — to add the file into the staging area

4) git commit -m “message” — to make your changes permanent

5) git push origin — to push your changes into the remote repository

6) git branch <qatesting> — to create a branch in the local system and then make changes and commit then push them too

7) git merge — to merge the branch with the master branch

some useful commands

1)git log — to find all versions of our files

2)git status — to get track information of all files

JOB 1-

→ Job 1 of Jenkins is to take files from GitHub and copy deploying it into TESTING SERVER

→ Click on “new item” to get started

→Click on “freestyle project” and add name

→ Select GIT and then link you GitHub profile where you want to download file

→Build trigger with “POLL SCM” in make Jenkins watch your GitHub every time

→Last step to “EXECUTE SHELL” and inform Jenkins where to put downloaded files

→In Linux, Jenkins user does not have all the privileges to manipulate files

| →By using “SUDO” command will give all power to Jenkins

→With this job, Jenkins will deploy files to the testing server (Here we launch new os only if our testing server is not running)

JOB 2-

Job 2 of Jenkins is to copy the file and deploy it to “PRODUCTION SERVER”

→Create a new job and give an appropriate name

→Link job2 with GitHub and

→Use POLLSCM to keep monitoring GitHub

→As shown in image use commands which copy files from GitHub and deploy into the webserver

→Here job 2 is completed

→But job2 is an “UPSTREAM PROJECT” which will only work if job 3 builds successfully

JOB 3-

→Job 3 is the main part of this system

→Job 2 is totally dependent on job 3. This is called “JOB CHAINING”

→First link your repository with storing credentials

→Then specify the branch you need to monitor and in advanced options give “MERGE BEFORE BUILD”. So this will merge branches and then build the job

→Job 3 is most sensitive because if this job gets wrong execution then our whole site in the production server gets harmed.

→In this job we use “BUILD TRIGGERS REMOTELY”

→So it will trigger just after the token is provided manually by the testing team

→As soon as the testing team pass and run the trigger, job 3 will run and our site will be in production server

→After the testing server approves, we no longer need the testing server

→So in EXECUTE SHELL we run the
script to destroy the testing server

THAT’S IT!! OUR WORK DONE THROUGH AUTOMATION SYSTEM

→FINAL OUTPUT OF OUR FILE

->OUTPUT OF DESTROYED TESTING SERVER!!

→GITHUB URL FOR REFERENCE- https://github.com/poojan1812/testing

→HAD A GOOD EXPERIENCE OF LEARNING AND BUILDING THIS PROJECT!!

FUTURE SCOPE -

→FURTHER WE CAN INTEGRATE THIS SYSTEM WITH VARIOUS TOOLS AND AUTOMATION SYSTEM.

→WE CAN INTEGRATE THIS WITH MACHINE LEARNING MODELS AND LINK THIS WHOLE WITH CLOUD COMPUTING TO TO CREATE A MASTERPIECE AUTOMATION SYSTEM WITH STORAGE EFFICIENCY INCLUDING ARTIFICIAL INTELLIGENCE

→THIS RAW SYSTEM CAN BE DIRECTLY USED EFFORTLESSLY IN DevOps WORLD

--

--

Poojan Mehta

In a continuous process of Technical Writing. Gathering, Organizing, Crafting the things that make sense.