The Essential Role of Continuous Integration (CI) in Modern Software Development

Listen to this Post

Continuous Integration (CI) is a software development practice where code changes are automatically built, tested, and integrated into a shared repository multiple times a day.

You Should Know:

1. Setting Up CI with Jenkins

Jenkins is a widely used CI tool. Below are the steps to set up a basic CI pipeline:

1. Install Jenkins (Linux):

sudo apt update
sudo apt install openjdk-11-jdk -y
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install jenkins -y
sudo systemctl start jenkins
sudo systemctl enable jenkins

2. Access Jenkins Dashboard:

Open `http://:8080` and complete the setup.

3. Create a New Pipeline:

  • Go to New Item > Pipeline.
  • Configure Git repository URL.
  • Add a `Jenkinsfile` to define build stages.

2. Automating Tests in CI

Example `.gitlab-ci.yml` for GitLab CI:

stages: 
- test 
- build

unit_tests: 
stage: test 
script: 
- npm install 
- npm test

build_project: 
stage: build 
script: 
- mvn clean package 

3. Using GitHub Actions for CI

Example workflow file (`.github/workflows/ci.yml`):

name: CI Pipeline

on: [push, pull_request]

jobs: 
build-and-test: 
runs-on: ubuntu-latest 
steps: 
- uses: actions/checkout@v2 
- name: Set up JDK 
uses: actions/setup-java@v2 
with: 
java-version: '11' 
- name: Build with Maven 
run: mvn clean package 
- name: Run Tests 
run: mvn test 

4. Essential CI Commands

  • Docker Build & Test:
    docker build -t my-app .
    docker run my-app npm test
    
  • Bash Script for Automated Testing:
    !/bin/bash
    set -e
    echo "Running tests..."
    pytest tests/
    echo "Tests passed!"
    

What Undercode Say:

CI is the backbone of Agile and DevOps, ensuring faster deployments, fewer bugs, and smoother team collaboration. By integrating automated testing, static code analysis (e.g., SonarQube), and deployment scripts, CI pipelines enhance software reliability.

Key Takeaways:

✔ Use Jenkins, GitLab CI, or GitHub Actions for automation.

✔ Always include unit, integration, and security tests.

✔ Monitor builds using tools like Prometheus + Grafana.

Expected Output:

A fully automated CI pipeline that builds, tests, and reports issues before merging code.

Further Reading:

References:

Reported By: Maheshma Cicd – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 TelegramFeatured Image