Skip to main content

Command Palette

Search for a command to run...

Full-Stack CI/CD with Jenkins: Auto-Builds, GitHub Webhooks & Dockerized Django

Updated
โ€ข5 min read
Full-Stack CI/CD with Jenkins: Auto-Builds, GitHub Webhooks & Dockerized Django
H

I'm a passionate Computer Science student specializing in DevOps, cloud technologies, and powerlifting. I've completed several certifications, including AWS Cloud Practitioner and Googleโ€™s Generative AI badge, and I'm currently exploring both AWS and Azure to build scalable, efficient CI/CD pipelines.

Through my blog posts, I share insights on cloud computing, DevOps best practices, and my learning journey in the tech space. I enjoy solving real-world problems with emerging technologies and am developing a platform to offer career advice to students. Outside of tech, I'm a competitive powerlifter, constantly striving to improve and inspire others in fitness.

Always eager to connect with like-minded individuals and collaborate on projects that bridge technology and personal growth.

In this article, I will show you how to:

  • Create a Jenkins Pipeline

  • Install required plugins

  • Configure GitHub Webhook

  • Enable automatic build trigger

  • Deploy a Django app using Docker

  • View pipeline stages using Stage View

This is a complete CI/CD implementation.


๐ŸŸข Step 1: Install Required Plugin (Stage View)

๐Ÿ“Œ Screenshot: Manage Jenkins โ†’ Plugins โ†’ Available Plugins

Search for:

Pipeline Aggregator View

๐Ÿ”น What is Pipeline Aggregator View?

  • Shows visual Stage View

  • Displays build history

  • Shows stage duration

  • Displays success/failure in green/red

Click Install.


๐ŸŸข Step 2: Create New Pipeline Job

๐Ÿ“Œ Screenshot: New Item Page

  1. Click New Item

  2. Enter name:

    djangocicd
    
  3. Select Pipeline

  4. Click OK


๐ŸŸข Step 3: General Configuration

๐Ÿ“Œ Screenshot: General Section

๐Ÿ”น Description

This is a CI/CD for a Django app

๐Ÿ”น GitHub Project (Enable)

Add repository URL:

https://github.com/LondheShubham153/django-notes-app.git

This connects Jenkins to GitHub.


๐Ÿ”น Other Options Explained

Option Purpose
Discard Old Builds Saves storage
Do Not Allow Concurrent Builds Prevents multiple runs
Pipeline Speed/Durability Override Performance tuning
Preserve Stashes Keeps temporary files
This Project is Parameterized Allows runtime parameters
Throttle Builds Limit parallel builds

๐ŸŸข Step 4: Configure Build Triggers

๐Ÿ“Œ Screenshot: Trigger Section

Enable:

โœ… GitHub hook trigger for GITScm polling

This allows Jenkins to build automatically when code is pushed.

Other options explained:

Option Use
Build Periodically Cron-based build
Poll SCM Checks repo every few minutes
GitHub Pull Requests PR trigger
Build After Other Projects Chain jobs

๐ŸŸข Step 5: Pipeline Script Configuration

๐Ÿ“Œ Screenshot: Pipeline Script Editor

Definition โ†’ Select:

Pipeline Script

Now paste this complete script:

pipeline {
    agent {
        label "hunter"
    }

    stages {

        stage("code") {
            steps {
                echo "Cloning the code"
                git url: "https://github.com/LondheShubham153/django-notes-app.git", branch: "main"
                echo "Code cloned successfully"
            }
        }

        stage("build") {
            steps {
                echo "Building Docker image"
                sh "whoami"
                sh "docker build -t notes-app:latest ."
                echo "Build successful"
            }
        }

        stage("test") {
            steps {
                echo "Running tests"
            }
        }

        stage("deploy") {
            steps {
                echo "Deploying container"
                sh "docker rm -f notes-app-container || true"
                sh "docker run -d -p 8000:8000 --name notes-app-container notes-app:latest"
                echo "Deployment successful"
            }
        }
    }

    post {
        always {
            echo "Pipeline finished"
        }
        success {
            echo "Pipeline executed successfully"
        }
        failure {
            echo "Pipeline failed"
        }
    }
}

๐Ÿ”น Use Groovy Sandbox

Keep this enabled for security.


๐ŸŸข Step 6: Setup GitHub Webhook

๐Ÿ“Œ Screenshot: GitHub โ†’ Settings โ†’ Webhooks

Click Add Webhook


๐Ÿ”น Payload URL

If using ngrok:

https://your-ngrok-url/github-webhook/

Example from screenshot:

https://unviolably-exostotic-cory.ngrok-free.dev/github-webhook/

๐Ÿ”น Content Type

Select:

application/json

๐Ÿ”น Secret

Optional but recommended for security.


๐Ÿ”น SSL Verification

Options:

Option Meaning
Enable SSL Verification Secure (Recommended)
Disable Not recommended

๐Ÿ”น Which Events to Trigger?

Select:

Send me everything

Or choose:

Just the push event

๐Ÿ”น Active

Make sure checkbox is enabled.

Click Update Webhook


๐ŸŸข Step 7: How Webhook Works

When you push code:

  1. GitHub sends POST request to Jenkins

  2. Jenkins receives webhook

  3. Pipeline automatically starts

  4. Stages execute sequentially

  5. Docker container gets deployed


๐ŸŸข Step 8: Stage View (Visual Pipeline Monitoring)

๐Ÿ“Œ Screenshot: Jenkins Stage View

You will see:

Stage Status Time
code โœ… Green 3s
build โœ… Green 1min 42s
test โœ… Green 41ms
deploy โœ… Green 3s

๐Ÿ”น What Stage View Shows

  • Build number (#11, #10, #9)

  • Stage duration

  • Average time

  • Success/Failure color coding

Green โ†’ Success

Red โ†’ Failed


๐ŸŸข Step 9: Access the Deployed Application

After deployment:

http://<server-ip>:8000

If running locally:

http://localhost:8000

๐ŸŸข Complete CI/CD Flow Architecture

Developer โ†’ Push Code โ†’ GitHub โ†’
Webhook โ†’ Jenkins โ†’
Build โ†’ Test โ†’ Deploy โ†’
Docker Container Running

๐ŸŽฏ Final Output

When everything is correct, you will see:

  • All stages green

  • Console output showing deployment

  • Running container on port 8000

  • Automatic trigger on every push


๐Ÿ”ฅ What Makes This Production-Ready?

  • Automated build

  • Dockerized deployment

  • Webhook integration

  • Stage monitoring

  • Error handling using post block

  • Container recreation logic


๐Ÿ Conclusion

In this guide, we:

โœ” Installed required plugin

โœ” Created pipeline job

โœ” Configured triggers

โœ” Wrote Declarative Jenkinsfile

โœ” Configured GitHub Webhook

โœ” Deployed Django app using Docker

โœ” Monitored pipeline using Stage View

This is a complete real-world CI/CD implementation.

More from this blog

Sundhar's Blog

28 posts