Hey Devs 👋 Krisha here!

In this article, we'll explore how to integrate GitHub Webhooks with Jenkins, even when Jenkins is running locally.
We'll use Ngrok to expose our local Jenkins server to the internet — allowing GitHub to notify Jenkins about repo changes automatically.

Let’s get started 🚀


✨ What is a Webhook?

A Webhook is a way for one application (like GitHub) to notify another (like Jenkins) when an event occurs — in real time.

“It’s like GitHub sending a push notification to Jenkins saying ‘Hey, new code was pushed!’


🛠️ The Problem

When Jenkins runs locally (on localhost:8080), GitHub can't reach it — because it’s not publicly accessible.

✅ The Solution → Use Ngrok

Ngrok creates a secure public URL and forwards traffic to your local machine.
This makes it possible for GitHub to reach Jenkins even if it's running on your laptop.


🚀 Step-by-Step Guide

1️⃣ Install Ngrok

If you don’t have Ngrok installed yet:

sudo apt install snapd
sudo snap install ngrok

Or download it from ngrok.com


2️⃣ Expose Jenkins (usually on port 8080)

ngrok http 8080

You’ll get output like:

Forwarding   https://abcd1234.ngrok.io -> http://localhost:8080

Copy the HTTPS link — you’ll need it soon.


3️⃣ Configure GitHub Webhook

  1. Go to GitHub Repo → Settings → Webhooks → Add webhook
  2. Set these fields:
Field Value
Payload URL https://abcd1234.ngrok.io/github-webhook/
(replace with your ngrok URL)
Content type application/json
Secret (Leave empty — optional)
SSL verification Enabled ✅
  1. Select ‘Just the push event’
  2. Click Save

4️⃣ Configure Jenkins GitHub Plugins

In Jenkins:

  • Go to Manage Jenkins → Manage Plugins → Installed
  • Ensure GitHub plugin and GitHub Integration Plugin are installed ✅

5️⃣ Configure Jenkins Job (Pipeline)

  1. Open your Jenkins job → Click Configure
  2. Scroll to Build Triggers
  3. Check ✅ GitHub hook trigger for GITScm polling

⚠️ Troubleshooting Common 403 Error (Invalid HTTP Response)

If GitHub webhook says Last delivery was not successful (403 Forbidden) — here’s the fix:

✅ Checklist

Task Status
GitHub hook trigger enabled in Jenkins
CSRF → "Enable proxy compatibility" checked
Webhook URL ends with /github-webhook/
Ngrok tunnel is active on port 8080
Jenkins restarted (optional)

Steps to Fix:

1️⃣ Allow anonymous POST (disable CSRF for hooks)
Manage Jenkins → Configure Global Security
➡️ Under CSRF Protection, enable "Enable proxy compatibility"

2️⃣ Ensure correct webhook URL
Your Payload URL should end with /github-webhook/
(not just root ngrok URL)

3️⃣ Restart Jenkins
(Optional, but clears stale settings)

sudo systemctl restart jenkins

4️⃣ Re-test webhook
In GitHub → Webhook → Click "Redeliver"
You should see HTTP 200 OK


⚡ Important Tips

  • Ngrok URL changes every time you restart ngrok
    Update the webhook URL in GitHub accordingly

  • Want a fixed Ngrok URL?
    Consider Ngrok paid plan with reserved subdomains


📊 How Does This Flow Work?

Here’s the data flow summary:

GitHub push → calls Webhook URL (ngrok) → forwards to Jenkins → Jenkins triggers Pipeline

📝 Conclusion

Using Ngrok + GitHub Webhooks + Jenkins gives you a powerful local CI/CD pipeline — even while developing on your laptop.

Now, every time you push to GitHub → Jenkins can auto-trigger builds, run tests, and more 🚀