In modern web development, automation is the key to speed and reliability. Instead of manually uploading files or rebuilding your project for every update, CI/CD (Continuous Integration and Continuous Deployment) ensures your website or application is built, tested, and deployed automatically whenever you push new code.
One of the most powerful tools for this is Jenkins — an open-source automation server used by companies like Netflix, LinkedIn, and Amazon.
In this detailed guide, you’ll learn how to set up a complete CI/CD pipeline using Jenkins to automatically deploy your website or web application from GitHub to your production environment.
See Also: How to Set Up Automated Website Deployment with GitHub Actions (Complete CI/CD Tutorial)
What Is CI/CD?
Before diving in, let’s break it down:
- Continuous Integration (CI): Every time you push changes, Jenkins builds and tests your project automatically to ensure everything still works.
- Continuous Deployment (CD): If the tests pass, Jenkins automatically deploys the latest version to your live server or hosting platform.
Together, they create a powerful, hands-free deployment workflow.
What Is Jenkins?
Jenkins is an automation tool written in Java. It runs on your server and can perform nearly any automated task:
- Building your site
- Running tests
- Deploying to a web host or server
- Sending notifications on success/failure
Why Use Jenkins for CI/CD?
- Completely free and open-source
- Highly customizable — works with any tech stack
- Supports plugins for Node.js, Python, Docker, GitHub, and more
- Integrates easily with servers, containers, and cloud platforms
- Ideal for both frontend and backend automation
Step 1: Install Jenkins
You can install Jenkins on Windows, macOS, or Linux.
For Ubuntu (recommended):
sudo apt update
sudo apt install openjdk-11-jdk
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt update
sudo apt install jenkins
sudo systemctl enable jenkins
sudo systemctl start jenkinsOpen Jenkins:
http://localhost:8080When prompted for the initial password:
sudo cat /var/lib/jenkins/secrets/initialAdminPasswordStep 2: Configure Jenkins
- Log in to Jenkins.
- Go to Manage Jenkins → Plugins → Available Plugins.
- Install the following:
- Git Plugin
- NodeJS Plugin (for JavaScript builds)
- Pipeline Plugin
- Publish Over SSH (for server deployment)
Once installed, restart Jenkins to activate the plugins.
See Also: How to Deploy a Website on Heroku (Step-by-Step Tutorial)
Step 3: Connect Your Git Repository
- Create a New Item → Freestyle Project (or Pipeline).
- Give it a name, e.g.,
MyWebsite-CICD. - Under Source Code Management, select Git.
- Add your repository URL (e.g.,
https://github.com/username/mywebsite.git). - If private, add GitHub credentials in Jenkins.
Step 4: Define Your Build and Deploy Steps
Depending on your project type, you can customize the build commands.
Example: Node.js / React / Next.js app
npm ci
npm run buildExample: Static site (HTML/CSS/JS)
echo "No build needed for static files"Example: Python / Flask app
pip install -r requirements.txt
pytestStep 5: Automate Deployment
You can use SSH, FTP, or even Docker to deploy.
Example (SSH to remote server):
Add this in your build “Execute Shell” step:
scp -r ./build/* user@yourserver:/var/www/html/Or use the Publish Over SSH plugin:
- Go to Manage Jenkins → Configure System → SSH Servers
- Add your server details (host, username, and private key)
- Then select this server in your project’s Post-Build Actions
Step 6: Create a Jenkins Pipeline (Optional but Recommended)
Pipelines are more flexible and easier to maintain.
Create a file in your repository named Jenkinsfile:
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git branch: 'main', url: 'https://github.com/username/mywebsite.git'
}
}
stage('Build') {
steps {
sh 'npm ci && npm run build'
}
}
stage('Test') {
steps {
sh 'npm test'
}
}
stage('Deploy') {
steps {
sh 'scp -r ./build/* user@yourserver:/var/www/html/'
}
}
}
}This script automates everything — from cloning to building to deploying.
Step 7: Automate Triggers
In Jenkins:
- Go to your project settings.
- Check “GitHub hook trigger for GITScm polling.”
- Add a webhook in your GitHub repo:
- URL:
https://your-jenkins-domain/github-webhook/ - Content Type:
application/json
- URL:
Now, every time you push code, Jenkins automatically builds and deploys.
Step 8: Secure Jenkins
Because Jenkins runs on your machine or server, secure it:
- Enable HTTPS (via reverse proxy or certbot).
- Restrict access using role-based authentication.
- Regularly update plugins to patch vulnerabilities.
Best Practices for CI/CD with Jenkins
- Use separate environments (staging vs production).
- Add automated tests before deploying.
- Integrate notifications (Slack, email) for build results.
- Use Docker for consistent build environments.
- Store secrets securely (avoid hardcoding credentials).
Conclusion
You’ve now set up a fully automated CI/CD pipeline with Jenkins — capable of building, testing, and deploying your website or app whenever you push new code.
Jenkins might take a bit more effort to set up than GitHub Actions, but it’s one of the most powerful, flexible, and scalable automation tools available today.
Next in Hosting Academy: you’ll learn how to deploy containerized applications using Docker Compose and Kubernetes — the next step in professional hosting automation.

