DEV Community

Poojan Mehta
Poojan Mehta

Posted on • Originally published at poojan-mehta.Medium on

Getting Started with CI/CD

→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  — 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  — 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

Billboard image

Deploy and scale your apps on AWS and GCP with a world class developer experience

Coherence makes it easy to set up and maintain cloud infrastructure. Harness the extensibility, compliance and cost efficiency of the cloud.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay