Skip to main content

Command Palette

Search for a command to run...

Day 12 - Introduction to CI/CD

Updated
β€’5 min read

🎯 What is CI/CD?

CI/CD stands for Continuous Integration and Continuous Delivery/Deployment.

It is a set of practices and automated processes that help teams build, test, and deliver software efficiently and reliably.


🧩 Why CI/CD is Needed

Before CI/CD, teams deployed applications manually β€” testing, scanning, and deploying took weeks or months.

With modern applications, users expect updates every few days or even hours, so companies must:

  • Deliver software quickly and safely

  • Ensure code quality and security

  • Reduce human effort and error

πŸ‘‰ CI/CD automates these steps.


βš™οΈ CI (Continuous Integration)

Continuous Integration is the process of automatically building and testing code whenever developers make changes.

Steps involved:

  1. Code Commit: Developers push code to a Version Control System (VCS) such as GitHub, GitLab, or Bitbucket.

  2. Build Process: The code is automatically compiled or built (e.g., using Maven for Java).

  3. Unit Tests: Automated unit tests verify small pieces of functionality.

  4. Static Code Analysis: Tools check for syntax errors, unused variables, and poor code practices (e.g., using SonarQube).

  5. Code Quality & Security Scan: Tools detect vulnerabilities and ensure secure code.

βœ… CI ensures that new code integrates smoothly with the existing codebase and remains stable.


πŸš€ CD (Continuous Delivery / Deployment)

After successful integration, the Continuous Delivery phase automates:

  1. Functional / Integration Testing: Ensures new code doesn’t break other features.

  2. Report Generation: Summarizes test results, code quality, and coverage.

  3. Deployment: Pushes code to environments like Dev, Staging, or Production.

Continuous Deployment goes one step further β€” automatically deploying to production without manual approval.


🧠 How CI/CD Works (Step-by-Step Example)

  1. A developer writes code locally (e.g., an addition feature in a calculator app).

  2. After testing locally, they push the code to a Git repository.

  3. A CI/CD tool (e.g., Jenkins, GitHub Actions, GitLab CI) detects the change.

  4. The tool triggers a pipeline β€” a series of automated steps:

    • Build the code

    • Run tests (unit, functional)

    • Perform code analysis

    • Generate reports

    • Deploy to servers (Dev β†’ Staging β†’ Production)


🧰 Common CI/CD Tools

CategoryExamples
Source ControlGitHub, GitLab, Bitbucket
CI/CD OrchestrationJenkins, GitHub Actions, GitLab CI, CircleCI, Travis CI
Build ToolsMaven, Gradle
Testing ToolsJUnit, Selenium
Code AnalysisSonarQube
DeploymentDocker, Kubernetes, AWS, Azure, GCP

πŸ—οΈ Example: Jenkins (Legacy CI/CD Tool)

Jenkins Workflow:

  1. Developer commits code β†’ GitHub repository.

  2. Jenkins detects the change (via webhook).

  3. Jenkins runs a Pipeline consisting of:

    • Build (Maven)

    • Unit Tests (JUnit)

    • Code Quality (SonarQube)

    • Reporting (Allure)

    • Deployment (to Kubernetes, EC2, etc.)

Jenkins as an Orchestrator

  • Jenkins integrates all tools together.

  • Pipelines can be written in Groovy (Declarative or Scripted Pipeline syntax).

  • Used widely for years, but has scaling limitations.


🧭 Environments in CI/CD

EnvironmentPurpose
DevFor developers to test early builds
StagingReplica of production; QA testing
ProductionFinal live environment for customers

Pipelines promote code automatically:

Dev β†’ Staging β†’ Production

Using manual approvals or automated policies.


⚠️ Limitations of Jenkins (Legacy Approach)

  • Requires manual setup of master and multiple worker nodes.

  • Scaling to handle hundreds of microservices becomes complex and expensive.

  • Continuous usage of compute resources (RAM/CPU), even when idle.

  • Difficult to achieve zero-resource usage when pipelines are inactive.


🌐 Modern CI/CD Solutions

Modern applications (like Kubernetes, Amazon, Flipkart) handle hundreds or thousands of microservices β€” they need scalable, on-demand CI/CD systems.

Example: Kubernetes Project on GitHub

  • Uses GitHub Actions for automation.

  • When a developer makes a pull request, a workflow runs automatically.

  • Containers (pods) are created temporarily to execute build/test steps.

  • After completion, the containers auto-delete β†’ no wasted resources.

βœ… Benefits:

  • Zero compute waste when idle

  • Shared runners for multiple projects

  • Fast scaling (pods start instantly)

  • Event-driven automation (no manual trigger)


⚑ Modern CI/CD Tools

ToolPlatformKey Features
GitHub ActionsGitHubEvent-driven, scalable, integrated with repositories
GitLab CIGitLabBuilt-in pipelines, YAML-based
CircleCICloudSimple config, fast builds
Travis CICloudGreat for open-source projects
Argo CD / TektonKubernetes-nativeCloud-native CI/CD pipelines

πŸ” Jenkins vs GitHub Actions β€” Quick Comparison

FeatureJenkinsGitHub Actions
TypeStandalone OrchestratorCloud/Repo-integrated
SetupManual installation & configurationBuilt into GitHub
ScalabilityManual node scalingAuto containerized runners
CostCompute always runningPay-per-use (zero idle cost)
TriggersWebhooksEvent-driven natively
Ideal ForOn-prem & traditional projectsCloud-native, modern apps

🧩 Summary

ConceptDescription
CI/CDAutomates integration, testing, and deployment
Continuous IntegrationMerges code frequently, runs builds/tests automatically
Continuous DeliveryDeploys to environments automatically after testing
ToolsJenkins, GitHub Actions, GitLab CI, CircleCI
Modern TrendCloud-native, event-driven, container-based pipelines
GoalFaster releases, fewer errors, and efficient resource use

βœ… In short:

CI/CD automates how your code goes from a developer’s laptop β†’ through build, test, and security checks β†’ to production servers β€” ensuring every release is fast, reliable, and safe.

More from this blog

Dinesh's Blog

104 posts