Skip to content

CI/CD

CI (Continuous Integration): Developers merge code frequently, each merge triggers automated build + tests. CD (Continuous Delivery): Code is always deployable; release requires manual approval. Continuous Deployment: Every change that passes tests is automatically deployed to production. Tools: Jenkins, GitHub Actions, GitLab CI, CircleCI. Key practices: automated testing, infrastructure as code, feature flags.

Key Concepts

Deep Dive: CI/CD Pipeline
Code Push → Build → Unit Tests → Integration Tests
Production ← Staging ← Deploy ← Artifact Store

GitHub Actions example:

name: CI/CD Pipeline
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-java@v4
      with:
        java-version: '21'
        distribution: 'temurin'
    - run: mvn clean verify
    - run: docker build -t my-app:${{ github.sha }} .

  deploy:
    needs: build
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
    - run: kubectl set image deployment/my-app my-app=my-app:${{ github.sha }}

Deep Dive: Deployment Strategies
Strategy Description Risk Rollback
Rolling Gradually replace pods Low Slow
Blue-Green Two environments, switch traffic Low Instant
Canary Route small % traffic to new version Very low Instant
Recreate Stop old, start new High (downtime) Slow
Deep Dive: Best Practices
  • Automate everything — build, test, deploy
  • Fast feedback — tests should run in minutes, not hours
  • Small, frequent changes — easier to debug and rollback
  • Feature flags — decouple deployment from release
  • Branch protection — require PR reviews and passing tests
  • Immutable artifacts — build once, deploy everywhere
Common Interview Questions
  • What is the difference between CI and CD?
  • What are deployment strategies? Explain Blue-Green.
  • How do you handle database migrations in CI/CD?
  • What is a feature flag?
  • How do you handle rollbacks?
  • What CI/CD tools have you used?