Day 12 - Introduction to CI/CD
π― 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:
Code Commit: Developers push code to a Version Control System (VCS) such as GitHub, GitLab, or Bitbucket.
Build Process: The code is automatically compiled or built (e.g., using Maven for Java).
Unit Tests: Automated unit tests verify small pieces of functionality.
Static Code Analysis: Tools check for syntax errors, unused variables, and poor code practices (e.g., using SonarQube).
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:
Functional / Integration Testing: Ensures new code doesnβt break other features.
Report Generation: Summarizes test results, code quality, and coverage.
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)
A developer writes code locally (e.g., an addition feature in a calculator app).
After testing locally, they push the code to a Git repository.
A CI/CD tool (e.g., Jenkins, GitHub Actions, GitLab CI) detects the change.
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
| Category | Examples |
| Source Control | GitHub, GitLab, Bitbucket |
| CI/CD Orchestration | Jenkins, GitHub Actions, GitLab CI, CircleCI, Travis CI |
| Build Tools | Maven, Gradle |
| Testing Tools | JUnit, Selenium |
| Code Analysis | SonarQube |
| Deployment | Docker, Kubernetes, AWS, Azure, GCP |
ποΈ Example: Jenkins (Legacy CI/CD Tool)
Jenkins Workflow:
Developer commits code β GitHub repository.
Jenkins detects the change (via webhook).
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
| Environment | Purpose |
| Dev | For developers to test early builds |
| Staging | Replica of production; QA testing |
| Production | Final 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
| Tool | Platform | Key Features |
| GitHub Actions | GitHub | Event-driven, scalable, integrated with repositories |
| GitLab CI | GitLab | Built-in pipelines, YAML-based |
| CircleCI | Cloud | Simple config, fast builds |
| Travis CI | Cloud | Great for open-source projects |
| Argo CD / Tekton | Kubernetes-native | Cloud-native CI/CD pipelines |
π Jenkins vs GitHub Actions β Quick Comparison
| Feature | Jenkins | GitHub Actions |
| Type | Standalone Orchestrator | Cloud/Repo-integrated |
| Setup | Manual installation & configuration | Built into GitHub |
| Scalability | Manual node scaling | Auto containerized runners |
| Cost | Compute always running | Pay-per-use (zero idle cost) |
| Triggers | Webhooks | Event-driven natively |
| Ideal For | On-prem & traditional projects | Cloud-native, modern apps |
π§© Summary
| Concept | Description |
| CI/CD | Automates integration, testing, and deployment |
| Continuous Integration | Merges code frequently, runs builds/tests automatically |
| Continuous Delivery | Deploys to environments automatically after testing |
| Tools | Jenkins, GitHub Actions, GitLab CI, CircleCI |
| Modern Trend | Cloud-native, event-driven, container-based pipelines |
| Goal | Faster 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.