In DevOps, automating your builds saves time and ensures fast feedback. With GitHub webhooks, Jenkins can automatically trigger a build when code is pushed.
This post walks you through how to connect Jenkins and GitHub using webhooks, so your CI/CD pipeline runs without any manual trigger.
๐ ๏ธ What You Need
- A running Jenkins server (local or on a cloud VM like EC2)
- A GitHub repository
- Git plugin installed in Jenkins
- Jenkins accessible from GitHub (via public IP, domain, or ngrok)
- Port 8080 open on your server
๐งฐ Step 1: Install Git Plugin in Jenkins
- Go to: Jenkins > Manage Jenkins > Plugin Manager
- Search for โGit pluginโ
- Install and restart Jenkins
Tip: Keep Jenkins updated to avoid integration issues.
๐งช Step 2: Create a Jenkins Job
- Click New Item > Freestyle project
- Name it:
github-webhook-demo
- Under Source Code Management, select Git
- Enter your GitHub repo URL
- In Build Triggers, check: rustCopyEdit
โ GitHub hook trigger for GITScm polling
- Add a build step โ
Execute shell
:
echo "Build triggered by GitHub webhook"
- Click Save
๐ Step 3: Setup GitHub Webhook
- Go to your GitHub repository
- Navigate to
Settings > Webhooks > Add webhook
- In Payload URL, use:
http://<your-server-ip>:8080/github-webhook/
If youโre using a reverse proxy or SSL, use HTTPS.
- Content Type:
application/json
- Choose: Just the push event
- Click Add webhook
๐งช Step 4: Test the Integration
Push a small change to your GitHub repo:
git add .
git commit -m "Test webhook"
git push origin main
Go to Jenkins and check if the build was triggered under Build History.
โ If you see a triggered job, it worked!
๐ฌ What Are Webhooks?
A webhook is a way for GitHub to notify Jenkins that an event occurred (like a code push). This lets Jenkins act instantly without polling.
๐ Real-Life Use Case
Imagine youโre working on a Node.js app. Each time your team pushes new code:
- Jenkins fetches the code
- Runs automated tests
- Builds and deploys the app
- Sends notification
This is true CI/CD automation powered by GitHub Webhooks + Jenkins.
๐ Internal Links
๐ External Links
๐ธ Suggested Images to Add
Add these screenshots to improve SEO:
- Jenkins job config screen
- GitHub webhook setup page
- Jenkins build console output after trigger
๐ง Final Thoughts
Integrating GitHub webhooks with Jenkins allows you to trigger jobs automatically. This creates a seamless CI/CD workflow and reduces delays in testing or deployment.