惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 最新话题
MyScale Blog
MyScale Blog
月光博客
月光博客
S
SegmentFault 最新的问题
C
CERT Recently Published Vulnerability Notes
P
Proofpoint News Feed
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
人人都是产品经理
人人都是产品经理
K
Kaspersky official blog
Forbes - Security
Forbes - Security
宝玉的分享
宝玉的分享
爱范儿
爱范儿
V
Visual Studio Blog
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
V
V2EX
The Cloudflare Blog
Attack and Defense Labs
Attack and Defense Labs
美团技术团队
L
LangChain Blog
NISL@THU
NISL@THU
IT之家
IT之家
T
Tor Project blog
云风的 BLOG
云风的 BLOG
Security Latest
Security Latest
Apple Machine Learning Research
Apple Machine Learning Research
Cisco Talos Blog
Cisco Talos Blog
I
InfoQ
Help Net Security
Help Net Security
Engineering at Meta
Engineering at Meta
Know Your Adversary
Know Your Adversary
I
Intezer
Recent Commits to openclaw:main
Recent Commits to openclaw:main
TaoSecurity Blog
TaoSecurity Blog
P
Palo Alto Networks Blog
GbyAI
GbyAI
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
T
The Exploit Database - CXSecurity.com
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - Franky
L
Lohrmann on Cybersecurity
The Register - Security
The Register - Security
W
WeLiveSecurity
Recorded Future
Recorded Future
大猫的无限游戏
大猫的无限游戏
AWS News Blog
AWS News Blog
G
GRAHAM CLULEY

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Jenkins CI/CD Pipeline for a Dockerized Node.js Application: Manual Trigger vs Automatic Trigger Using GitHub Webhooks
Omkar Sharma · 2026-05-23 · via DEV Community

Have you ever pushed code to GitHub and wished your application could automatically build and deploy itself without logging into a server or clicking a button in Jenkins? In this article, you'll learn how to build a complete CI/CD pipeline for a Dockerized Node.js application using Jenkins, starting with manual deployments and progressing to fully automated deployments using GitHub webhooks.

We will cover:

  • Creating a Jenkins pipeline
  • Building a Docker image
  • Deploying a container
  • Triggering builds manually
  • Triggering builds automatically
  • GitHub Personal Access Tokens
  • Fine-grained vs Classic Tokens
  • Jenkins credentials
  • GitHub webhooks
  • Required Jenkins plugins
  • Common errors and troubleshooting The goal is to understand not only how to configure everything but also why each component is needed.

Node.js Application Repo URL- https://github.com/omkarsharma2821/Node.js-App-Deploy-Github-Action

Architecture Overview

The complete flow looks like this:

Developer
    |
    | Git Push
    v
GitHub Repository
    |
    | Webhook
    v
Jenkins
    |
    | Build Docker Image
    v
Docker
    |
    | Run Container
    v
Application Running

Enter fullscreen mode Exit fullscreen mode

Without webhooks:

Developer
    |
    | Git Push
    v
GitHub Repository

Jenkins Build Now (Manual Trigger)
    |
    v
Build and Deploy

Enter fullscreen mode Exit fullscreen mode

With webhooks:

Developer
    |
    | Git Push
    v
GitHub Repository
    |
    v
Webhook
    |
    v
Jenkins
    |
    v
Build and Deploy Automatically

Enter fullscreen mode Exit fullscreen mode

Prerequisites

Before starting, ensure you have:

  • Ubuntu Server
  • Jenkins installed
  • Docker installed
  • Git installed
  • GitHub repository
  • Node.js application with Dockerfile Verify installations:
jenkins --version
docker --version
git --version

Enter fullscreen mode Exit fullscreen mode

Installing Docker on Jenkins Server

Install Docker:

sudo apt update
sudo apt install docker.io -y

Enter fullscreen mode Exit fullscreen mode

Enable Docker:

sudo systemctl enable docker
sudo systemctl start docker

Enter fullscreen mode Exit fullscreen mode

Verify:

docker --version

Enter fullscreen mode Exit fullscreen mode

Allow Jenkins to Use Docker

By default Jenkins cannot execute Docker commands.

Add Jenkins user to Docker group:

sudo usermod -aG docker jenkins

Enter fullscreen mode Exit fullscreen mode

Restart Jenkins:

sudo systemctl restart jenkins

Enter fullscreen mode Exit fullscreen mode

Verify:

sudo su - jenkins
docker ps

Enter fullscreen mode Exit fullscreen mode

If Docker works without sudo, Jenkins is ready.

Creating the Pipeline

Initially we created a Jenkins pipeline that manually clones the repository.

Example:

pipeline {
    agent any

    stages {

        stage('Clone Repository') {
            steps {
                sh '''
                    mkdir -p devops
                    cd devops
                    rm -rf Node.js-App-Deploy-Github-Action
                    git clone -b main https://github.com/username/repository.git
                '''
            }
        }

        stage('Build Image') {
            steps {
                sh '''
                    cd devops/Node.js-App-Deploy-Github-Action
                    docker build -t node-app .
                '''
            }
        }

        stage('Deploy') {
            steps {
                sh '''
                    docker run -d -p 8000:8080 node-app
                '''
            }
        }
    }
}

Enter fullscreen mode Exit fullscreen mode

This works, but every deployment requires manually clicking:

Build Now

Enter fullscreen mode Exit fullscreen mode

Problem with Multiple Deployments

Suppose the application is already running.

Running:

docker run -d -p 8000:8080 node-app

Enter fullscreen mode Exit fullscreen mode

again will fail because port 8000 is already occupied.

Error:

Bind for 0.0.0.0:8000 failed

Enter fullscreen mode Exit fullscreen mode

Better Deployment Approach

Before starting a new container, remove the old one.

docker rm -f node-app-container || true

Enter fullscreen mode Exit fullscreen mode

Then start a new container:

docker run -d --name node-app-container -p 8000:8080 node-app

Enter fullscreen mode Exit fullscreen mode

Understanding docker rm -f node-app-container || true

Let's break it down.

docker rm

Removes a container.

docker rm node-app-container

Enter fullscreen mode Exit fullscreen mode

Works only if container is stopped.

-f

Force remove.

docker rm -f node-app-container

Enter fullscreen mode Exit fullscreen mode

This:

  1. Stops container
  2. Removes container

||

OR operator.

Syntax:

command1 || command2

Enter fullscreen mode Exit fullscreen mode

If command1 fails, command2 executes.

true

Always returns success.

true

Enter fullscreen mode Exit fullscreen mode

Exit code:

0

Enter fullscreen mode Exit fullscreen mode

Final Meaning

docker rm -f node-app-container || true

Enter fullscreen mode Exit fullscreen mode

If container exists:

Remove it

Enter fullscreen mode Exit fullscreen mode

If container doesn't exist:

Ignore error and continue

Enter fullscreen mode Exit fullscreen mode

This prevents Jenkins from failing.

Manual Triggering

The simplest approach is manual execution.

Navigate to:

Jenkins Job
|
└── Build Now

Enter fullscreen mode Exit fullscreen mode

Advantages:

  • Easy to understand
  • Good for learning
    Disadvantages:

  • Requires human intervention

  • Not real CI/CD

Automatic Triggering

The goal of CI/CD is:

Code Push
    |
    v
Automatic Build
    |
    v
Automatic Deployment

Enter fullscreen mode Exit fullscreen mode

This is where GitHub webhooks come into play.

Required Jenkins Plugins

Install the following Jenkins plugins before configuring the CI/CD pipeline:

1. Git Plugin

  • Enables Jenkins to interact with Git repositories.
  • Allows Jenkins to clone repositories, fetch changes, and checkout specific branches.
  • Required for integrating Jenkins with GitHub repositories.

2. GitHub Plugin

  • Provides integration between Jenkins and GitHub.
  • Allows Jenkins to communicate with GitHub repositories and services.
  • Supports GitHub-related features within Jenkins.

3. GitHub Integration Plugin

  • Enables GitHub webhook support.
  • Allows Jenkins to automatically trigger builds when code is pushed to GitHub.
  • Essential for implementing automated CI/CD workflows.

4. Pipeline Plugin

  • Enables support for Jenkins Pipelines.
  • Allows execution of Jenkinsfiles written in Declarative or Scripted Pipeline syntax.
  • Required for defining CI/CD workflows as code.

5. Credentials Plugin

  • Provides secure storage for sensitive information.
  • Allows storing:
    • GitHub Personal Access Tokens (PATs)
    • Usernames and passwords
    • SSH keys
    • API tokens
  • Prevents hardcoding secrets in Jenkins jobs and pipelines.

GitHub Authentication

When Jenkins needs to access a GitHub repository, authentication requirements depend on the repository type.

Public Repository

  • Can typically be cloned without authentication.

Example:

git clone https://github.com/username/repository.git

Enter fullscreen mode Exit fullscreen mode

Private Repository

  • Requires authentication.
  • GitHub no longer supports account passwords for Git operations.
  • A Personal Access Token (PAT) must be used instead of a password.

Why Use a Personal Access Token (PAT)?

  • More secure than passwords.
  • Allows granular permission control.
  • Can be revoked without affecting your GitHub account password.
  • Recommended by GitHub for all Git operations requiring authentication.

Classic Personal Access Token

Older token type.

Advantages:

  • Simple
  • Easy to configure
    Disadvantages:

  • Broad permissions

  • Less secure
    Example scopes:

repo
workflow
admin:repo_hook

Enter fullscreen mode Exit fullscreen mode

Fine-Grained Personal Access Token

Newer and recommended approach.

Advantages:

  • Repository-level access
  • Better security
  • Granular permissions Example:
Repository Access:
Only selected repositories

Enter fullscreen mode Exit fullscreen mode

Permissions:

Contents: Read and Write
Metadata: Read
Webhooks: Read and Write

Enter fullscreen mode Exit fullscreen mode

Fine-Grained vs Classic Token

Feature Fine-Grained Classic
Security High Lower
Repository Scope Specific Broad
Permission Control Granular Broad
Recommended Yes Legacy

For modern projects, prefer Fine-Grained tokens.

Adding GitHub Token to Jenkins

Navigate to:

Manage Jenkins
|
Credentials

Enter fullscreen mode Exit fullscreen mode

Select:

Global Credentials

Enter fullscreen mode Exit fullscreen mode

Choose:

Add Credentials

Enter fullscreen mode Exit fullscreen mode

Kind:

Username with Password

Enter fullscreen mode Exit fullscreen mode

Example:

Username: GitHub Username
Password: Personal Access Token

Enter fullscreen mode Exit fullscreen mode

ID:

github-creds

Enter fullscreen mode Exit fullscreen mode

Save.

Pipeline Script vs Pipeline Script from SCM

Many beginners get confused here.

Pipeline Script

Pipeline stored inside Jenkins UI.

Example:

pipeline {
    agent any
}

Enter fullscreen mode Exit fullscreen mode

Advantages:

  • Quick setup
    Disadvantages:

  • Not version controlled

  • Difficult to maintain

Pipeline Script from SCM

Pipeline stored in GitHub repository.

Repository structure:

project/
|
|-- Dockerfile
|-- package.json
|-- app.js
|-- Jenkinsfile

Enter fullscreen mode Exit fullscreen mode

Jenkins automatically downloads Jenkinsfile.

Advantages:

  • Version controlled
  • Industry standard
  • Easier maintenance Recommended approach.

Configuring Pipeline from SCM

Create Jenkins job.

Select:

Pipeline

Enter fullscreen mode Exit fullscreen mode

Under Definition:

Pipeline script from SCM

Enter fullscreen mode Exit fullscreen mode

SCM:

Git

Enter fullscreen mode Exit fullscreen mode

Repository URL:

https://github.com/username/repository.git

Enter fullscreen mode Exit fullscreen mode

Branch:

*/main

Enter fullscreen mode Exit fullscreen mode

Script Path:

Jenkinsfile

Enter fullscreen mode Exit fullscreen mode

Save.

Creating GitHub Webhook

Navigate to:

GitHub Repository
|
Settings
|
Webhooks
|
Add Webhook

Enter fullscreen mode Exit fullscreen mode

Payload URL:

http://JENKINS_PUBLIC_IP:8080/github-webhook/

Enter fullscreen mode Exit fullscreen mode

Content Type:

application/json

Enter fullscreen mode Exit fullscreen mode

Event:

Just the push event

Enter fullscreen mode Exit fullscreen mode

Save webhook.

Configuring Jenkins Trigger

Open job configuration.

Under Build Triggers:

Select:

GitHub hook trigger for GITScm polling

Enter fullscreen mode Exit fullscreen mode

Save.

Testing the Webhook

Push code:

git add .
git commit -m "testing webhook"
git push origin main

Enter fullscreen mode Exit fullscreen mode

Expected flow:

GitHub Push
    |
    v
Webhook
    |
    v
Jenkins
    |
    v
Pipeline Starts

Enter fullscreen mode Exit fullscreen mode

No manual click required.


Common Troubleshooting

Webhook Returns 404

Cause:

Wrong webhook URL

Enter fullscreen mode Exit fullscreen mode

Correct:

http://SERVER-IP:8080/github-webhook/

Enter fullscreen mode Exit fullscreen mode

Webhook Returns 403

Cause:

Authentication or security issue

Enter fullscreen mode Exit fullscreen mode

Verify:

  • GitHub plugin
  • GitHub integration plugin

Webhook Returns 200 But Build Doesn't Start

Common cause:

Pipeline Script instead of Pipeline Script from SCM

Enter fullscreen mode Exit fullscreen mode

or

Repository mapping issue

Enter fullscreen mode Exit fullscreen mode

Dockerfile Not Found

Example:

unable to evaluate symlinks in Dockerfile path

Enter fullscreen mode Exit fullscreen mode

Cause:

Wrong working directory.

Check:

pwd
ls -la

Enter fullscreen mode Exit fullscreen mode

Verify Dockerfile location.

Permission Denied While Running Docker

Cause:

Jenkins not in docker group

Enter fullscreen mode Exit fullscreen mode

Fix:

sudo usermod -aG docker jenkins
sudo systemctl restart jenkins

Enter fullscreen mode Exit fullscreen mode

Final Jenkinsfile

pipeline {
    agent any

    stages {

        stage('Build Image') {
            steps {
                sh '''
                    docker build -t node-app .
                '''
            }
        }

        stage('Deploy') {
            steps {
                sh '''
                    docker rm -f node-app-container || true
                    docker run -d --name node-app-container -p 8000:8080 node-app
                '''
            }
        }
    }
}

Enter fullscreen mode Exit fullscreen mode

Conclusion

A Jenkins pipeline can be triggered manually or automatically. Manual triggering is useful for learning and testing, but real CI/CD begins when code pushes automatically trigger builds and deployments.

The recommended production approach is:

  1. Store the Jenkinsfile in GitHub.
  2. Use Pipeline Script from SCM.
  3. Configure GitHub credentials using a Personal Access Token.
  4. Enable GitHub webhook integration.
  5. Use Docker for packaging and deployment.
  6. Remove old containers before deploying new versions. With this setup, every code push automatically builds a Docker image, deploys a fresh container, and updates the application without requiring any manual intervention.

✍️ Author: Omkar Sharma

📬 Feel free to connect on LinkedIn or explore more on GitHub