Knowledge / Information Technology / DevOps and CI/CD basics

DevOps and CI/CD basics

Information Technology (B.E./B.Tech) · Infrastructure and operations · free study notes for exams, placements and interviews

In short

DevOps is a working practice that merges software development and IT operations so that code moves from a developer's laptop to production in small, frequent, automated and reversible steps. Its engine is the CI/CD pipeline: continuous integration builds and tests every commit, continuous delivery keeps every build releasable, and continuous deployment pushes passing builds to production automatically. It matters because manual builds and quarterly "big bang" releases are the main source of integration conflicts, failed deployments and long outages. It is examined in AICTE/CBCS electives on Software Engineering, DevOps and Agile Software Development, and asked in almost every Indian IT placement interview — TCS, Infosys, Wipro, Accenture, Cognizant, HCLTech, LTIMindtree, Tech Mahindra and product firms such as Zoho, Flipkart, Razorpay and Freshworks hire explicitly for "DevOps engineer" and "SRE/build engineer" roles. Expect questions on pipeline stages, Git branching, Jenkinsfiles, IaC and deployment strategies rather than heavy mathematics.

Explained

Why DevOps exists: the wall of confusion

Version control and branching (the foundation)

Continuous Integration (CI)

Continuous Delivery, Continuous Deployment and pipelines

Infrastructure as Code, containers and configuration

DevSecOps, measurement and governance

Key points

Formulas and examples

Lead time for changes = (timestamp of production deploy) − (timestamp of commit), in hours
Deployment frequency = number of successful production deployments ÷ time period (per day/week)
Change failure rate (%) = (deployments causing incident, rollback or hotfix ÷ total deployments) × 100
MTTR = total restoration time ÷ number of incidents (hours or minutes)
Build success rate (%) = (successful builds ÷ total builds) × 100
Pipeline duration = Σ(stage durations) for sequential stages; = max(stage durations) for stages run in parallel
Deployment cost = (pipeline minutes × rate per minute) + (agent/runner hours × hourly rate), in ₹
Availability (%) = (total time − downtime) ÷ total time × 100; error budget = 100% − SLO target
Parallel speed-up (Amdahl) S = 1 ÷ (s + p/N); s = serial fraction, p = parallelisable fraction, N = workers

Example 1 - DORA metrics for a release train. A Pune fintech team made 48 production deployments in 30 days. Five caused incidents needing a rollback or hotfix. Total restoration time across those five was 7 hours 30 minutes. Median commit-to-production time was 9 hours.

Example 2 - cutting pipeline time by parallelising. A Jenkins pipeline has: checkout 1 min, compile 4 min, unit tests 12 min, SonarQube scan 6 min, image build 3 min, push 2 min.

Example 3 - cost of a self-hosted runner versus hosted minutes. A team runs 60 builds a day, 22 working days a month, each build 16 minutes.

Example 4 - canary release risk arithmetic. A new build has an unknown defect that would fail 2% of requests. The service takes 500 requests per second and the canary carries 5% of traffic for 10 minutes before automatic rollback.

Example 5 - availability and the cost of a manual release window. A team releases monthly with a 90-minute planned downtime window; monthly period = 30 × 24 × 60 = 43,200 minutes.

AspectContinuous IntegrationContinuous DeliveryContinuous Deployment
Scope ends atTested artefact in repositoryArtefact deployable on demandArtefact live in production
Human gateNone (after commit)Yes — approval to releaseNone
Key needSelf-testing buildAutomated acceptance tests, prod-like stagingMature monitoring, canary, auto-rollback
Typical triggerEvery push/PREvery green CI buildEvery green pipeline
StrategyDowntimeRollback speedExtra infraMonitoring need
RecreateYesSlow (redeploy old)NoneLow
Rolling updateNoMediumSmallMedium
Blue-greenNoInstant (switch LB)~2× brieflyMedium
CanaryNoFast (stop ramp)SmallHigh
Feature flagNoInstant (toggle off)NoneMedium
ToolCategoryNote
Git, GitHub, GitLab, BitbucketSource controlBitbucket common in Indian service firms
Jenkins, GitHub Actions, GitLab CI, Azure DevOpsCI/CD orchestrationJenkins still dominates Indian enterprise estates
Maven, Gradle, npmBuildPin versions for reproducibility
Nexus, Artifactory, ECR, ACRArtefact/image registryBuild once, promote
Terraform, Ansible, CloudFormationIaCProvision vs configure
Argo CD, Flux, SpinnakerDeployment/GitOpsPull-based reconciliation
SonarQube, Trivy, OWASP ZAP, gitleaksDevSecOpsQuality and security gates
Prometheus, Grafana, ELKPipeline and release feedbackDetail in the monitoring/SRE topic
// Jenkinsfile - declarative pipeline, build once and promote
pipeline {
  agent { docker { image 'maven:3.9-eclipse-temurin-21' } }
  options { timeout(time: 20, unit: 'MINUTES') }
  environment { IMG = "registry.example.in/payments:${env.GIT_COMMIT.take(7)}" }
  stages {
    stage('Build')  { steps { sh 'mvn -B -ntp clean package' } }
    stage('Checks') {
      parallel {
        stage('Unit tests') { steps { sh 'mvn -B test' } }
        stage('SAST')       { steps { sh 'mvn -B sonar:sonar' } }
      }
    }
    stage('Image') { steps { sh "docker build -t $IMG . && trivy image --exit-code 1 --severity CRITICAL $IMG && docker push $IMG" } }
    stage('Deploy staging') { steps { sh "kubectl -n staging set image deploy/payments app=$IMG" } }
    stage('Approve prod')   { steps { timeout(time: 2, unit: 'HOURS') { input message: 'Release to production?' } } }
    stage('Deploy prod')    { steps { sh "kubectl -n prod set image deploy/payments app=$IMG" } }
  }
  post { always { junit 'target/surefire-reports/*.xml' } failure { echo 'Build broken - stop the line' } }
}
# .github/workflows/ci.yml - CI on every push and pull request
name: ci
on: { push: { branches: [main] }, pull_request: {} }
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with: { node-version: '22', cache: 'npm' }
      - run: npm ci
      - run: npm run lint
      - run: npm test -- --coverage
      - run: npm audit --audit-level=high
      - uses: actions/upload-artifact@v4
        with: { name: dist, path: dist/ }

Where it is used

Interview questions

Common mistakes

Related topics

Containers: Docker and Kubernetes · Cloud computing basics · Monitoring and site reliability engineering · IT service management and ITIL · Software engineering and agile methodologies · Linux command line essentials

Open in the Knowledge reader →Find jobs →