CI/CD Pipeline with GitHub & Jenkins

Automate build and deployment using industry-standard DevOps pipelines.

CI/CD (Continuous Integration and Continuous Deployment) is a core DevOps practice that helps teams deliver software faster and with fewer errors. In this guide, we’ll build a CI/CD pipeline using GitHub and Jenkins.

What is CI/CD?

Continuous Integration ensures that every code change is automatically built and tested. Continuous Deployment automates releasing code to production environments.

Tools Used in This Pipeline

Step 1: Setup Jenkins Server

Install Jenkins on a Linux machine:


sudo apt update
sudo apt install openjdk-17-jdk -y
sudo apt install jenkins -y
      

Step 2: Create Jenkins Job

Create a new pipeline job in Jenkins and connect it with your GitHub repository using credentials.

Step 3: Configure GitHub Webhook

Add a webhook in GitHub so Jenkins triggers automatically on every code push.

Step 4: Jenkins Pipeline (Jenkinsfile)

Example Jenkins pipeline:


pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        echo 'Building application'
      }
    }
    stage('Deploy') {
      steps {
        echo 'Deploying application'
      }
    }
  }
}
      

Benefits of CI/CD