Search Knowledge

© 2026 LIBREUNI PROJECT

DevOps and CI/CD

DevOps and CI/CD

In modern software engineering, the boundary between “development” and “operations” has blurred. DevOps is a set of practices, tools, and a cultural philosophy that automate and integrate the processes between software development and IT teams.

The DevOps Lifecycle

  1. Plan: Requirement gathering and project management.
  2. Code: Development and version control.
  3. Build: Compiling code and managing dependencies.
  4. Test: Automated unit, integration, and security tests.
  5. Release: Preparing the artifact for deployment.
  6. Deploy: Pushing the code to production or staging.
  7. Operate: Managing the infrastructure.
  8. Monitor: Tracking performance and user experience.

CI/CD: The Engine of DevOps

Continuous Integration (CI)

CI is the practice of merging all developer working copies to a shared mainline several times a day.

  • Goal: Catch integration bugs early.
  • Key Action: Every commit triggers an automated build and test suite.

Continuous Delivery (CD)

Continuous Delivery is an extension of CI to ensure that you can release new changes to your customers quickly in a sustainable way.

  • Goal: The codebase is always in a deployable state.
  • Key Action: Automated release process, but deployment to production might be manual.

Continuous Deployment (CD)

Every change that passes all stages of your production pipeline is released to your customers. There is no human intervention.

Designing a CI/CD Pipeline

A typical pipeline consists of several stages:

1. Source Stage

Triggered by a code change in a repository (e.g., GitHub, GitLab, Bitbucket).

2. Build Stage

The application is compiled, and artifacts (like JAR files, Docker images) are created.

3. Test Stage

  • Unit Tests: Verify individual components.
  • Static Analysis (Linting): Check for code style and potential bugs (e.g., SonarQube).
  • Security Scanning: Check for vulnerabilities in dependencies.

4. Deploy Stage

Artifacts are deployed to environments (Staging, then Production). Use techniques like Blue-Green Deployment or Canary Releases to minimize risk.

Example: GitHub Actions Workflow (YAML)

GitHub Actions allows you to define your CI/CD pipeline in a .yaml file within your repository.

# .github/workflows/ci.yml
name: Java CI with Maven

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    
    - name: Set up JDK 17
      uses: actions/setup-java@v3
      with:
        java-version: '17'
        distribution: 'temurin'
        cache: maven
        
    - name: Build and Test with Maven
      run: mvn -B package --file pom.xml

    - name: Run Static Analysis
      run: mvn sonar:sonar
      env:
        SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
        
    - name: Upload Artifact
      uses: actions/upload-artifact@v3
      with:
        name: app-jar
        path: target/*.jar

Benefits of CI/CD

  • Reduced Risk: Smaller changes are easier to test and revert.
  • Faster Time to Market: Features reach users in hours or days instead of months.
  • Increased Productivity: Developers spend less time on manual deployment and more on code.
  • Better Quality: Constant automated testing ensures regressions are caught immediately.

Infrastructure as Code (IaC)

DevOps often involves managing infrastructure through code (e.g., Terraform, CloudFormation, Ansible). This allows you to version control your server configurations just like your application code.