Jenkins helps you deliver updates faster while ensuring consistency in your deployments. Instead of repeating manual steps, you can use a pipeline to handle the creation, testing, and deployment of your application with every change. In this guide, we’ll show you how to set up a simple but effective Jenkins pipeline to support continuous integration and continuous deployment on your server.
What Is a Deployment Pipeline
A deployment pipeline is an automated sequence of steps that transfers code from development to production. Since the same workflow is executed every time, you avoid the small errors that often occur with manual deployments. Continuous deployment builds on this concept by automatically releasing every change that passes all tests. This means that code that works in tests can be deployed to your live environment without additional approval steps.
Why Jenkins Is a Strong Choice
Jenkins works well for both early-stage projects and mature production setups. It connects smoothly with Git, pulls your code, and runs automated steps like building and testing. After the build process, Jenkins can deploy to your server, making it a practical choice for running applications on a VPS. Since Jenkins runs the same defined pipeline each time, you gain control and predictability while still moving quickly.
Setting Jenkins Up on Your Server
Start by installing Jenkins on your server. If you use an Ubuntu-based VPS, you can do this directly through the package manager by running:
sudo apt update
sudo apt install jenkins Once the installation finishes, open your browser and access Jenkins at http://your-server-ip:8080. From there, you can reach the Jenkins dashboard and begin creating your first pipeline job.
Creating a New Pipeline
From the Jenkins dashboard, click New Item, name your pipeline, and choose Pipeline as the project type. After you click OK, Jenkins will take you to the configuration page where you define how your continuous deployment workflow should run. This is where the pipeline becomes your “single source of truth” for how code moves from commit to production.
Defining Your Jenkins Pipeline Script
In the configuration screen, scroll to the Pipeline section and find the script area. Here you can use a declarative pipeline that keeps the process readable and structured. A basic setup can look like this:
pipeline {
agent any
stages {
stage('Clone') {
steps {
git 'https://github.com/your-repo.git'
}
}
stage('Build') {
steps {
sh './build.sh'
}
}
stage('Test') {
steps {
sh './run-tests.sh'
}
}
stage('Deploy') {
steps {
sh './deploy.sh'
}
}
}
} This pipeline ties your workflow together in one connected run. It starts by cloning your repository, then it builds your application, and right after that it runs your automated tests. Once the tests pass, it moves straight into deployment by executing your deploy script, which means the full path from code to production stays consistent every time.
Add Security and Access Controls
Before you rely on the pipeline for production releases, you should secure access properly. Jenkins often needs credentials for Git, SSH, or other services used during deployments. Therefore, you should store this sensitive data in the Jenkins Credentials Manager. This keeps sensitive information out of scripts and makes it easier to manage changes later, especially when more team members are working on the pipeline.
Use Cases for Continuous Deployment
Once your pipeline runs reliably, it can support common production tasks without extra effort from your side. For example, if you run a Node.js app on a Contabo VPS, Jenkins can run your tests automatically after every commit and then deploy the new build if everything passes. After deployment, you can also restart services using pm2 or Docker, which helps ensure the new version runs immediately.
To make deployments safer, you can connect post-deploy steps into the same flow. Health checks can confirm that the app responds as expected, and rollback scripts can help you recover quickly if something breaks. On top of that, alerts and notifications, such as Slack messages, can keep your team informed when deployments succeed or fail. Monitoring tools like Prometheus, New Relic, or log watchers help you stay aware of issues after each release.
YouTube Video on Deployment Pipelines with Jenkins
If you prefer a visual walkthrough, you can watch the connected YouTube video.
Final Thoughts
With a Jenkins pipeline in place, you combine continuous integration and continuous deployment into one automated process. Your code gets tested after each push, and successful changes can move directly into production without manual deployment steps. Because Jenkins keeps everything defined in one pipeline script, you also keep full control over how releases happen.