Sign in
Topics
Automate your entire build with simple prompts or Figma imports
Still using manual deployment in 2025? Master the Jenkins CI/CD pipeline to automate builds, reduce errors, and speed up delivery. This blog covers setup, pipelines, integrations, and practical tips for real-world projects.
Still deploying code manually and hoping everything goes right? That may have worked in the past, but today, it slows teams down and leaves too much room for error. Fast-moving development cycles demand speed, consistency, and reliability from the start.
So, how do you deliver high-quality software without compromising on stability?
Manual processes introduce delays and bugs that modern teams can't afford. That's why many are turning to automation, and Jenkins leads the way. With the right Jenkins CI/CD pipeline, you can automate builds, reduce mistakes, and ship with confidence.
This article guides you through the process of installing Jenkins, building both declarative and scripted pipelines, integrating tools such as Git and Maven, and optimizing your pipeline for enhanced performance and scalability.
The Jenkins CI/CD pipeline is a series of automated steps to build, test, and deploy your software. It integrates continuous integration (CI), where developers frequently merge code, with continuous delivery (CD), ensuring that validated code is always ready for release. Jenkins, as an open-source automation server, facilitates this process using a pipeline plugin, enabling teams to treat deployment workflows as code.
Using a Jenkins pipeline brings several benefits:
Automates repetitive tasks like testing and deployment.
Improves visibility with detailed console output and build history.
Supports both declarative and scripted pipelines, accommodating different use cases.
Integrates with a wide range of tools, including Git, Docker, Maven, and Tomcat.
Enables parallel stages, conditional logic, and robust error handling.
Term | Meaning |
---|---|
Pipeline | Defines the full software delivery process, from source to production. |
Stage | Logical division of work, e.g., Build, Test, Deploy. |
Step | A single task, such as compiling code or running a script. |
Node block | Used in scripted pipelines to define where steps run. |
Pipeline block | The root element in declarative pipelines. |
Environment directive | Defines environment variables accessible across stages. |
To install Jenkins, follow these steps:
Download from the official Jenkins site.
Run using java -jar jenkins.war
.
Access the Jenkins web UI at http://localhost:8080
.
Retrieve the initial admin password from the terminal or the initialAdminPassword
file.
Install suggested plugins or choose from a few options manually.
Create the first admin user and configure the Jenkins URL.
This process sets up your Jenkins server and gets you ready to create Jenkins jobs.
Jenkins supports two pipeline syntaxes: declarative pipeline and scripted pipeline.
Let’s break them down.
Structured and beginner-friendly.
Uses the pipeline
block with nested stages.
Ideal for most CI/CD setups.
Example:
1pipeline { 2 agent any 3 stages { 4 stage('Build') { 5 steps { 6 echo 'Building...' 7 } 8 } 9 stage('Test') { 10 steps { 11 echo 'Testing...' 12 } 13 } 14 stage('Deploy') { 15 steps { 16 echo 'Deploying...' 17 } 18 } 19 } 20}
Written in full Groovy, offering more flexibility.
Uses the node
block to define steps.
Better for advanced users or complex logic.
Example:
1node { 2 stage('Build') { 3 echo 'Building...' 4 } 5 stage('Test') { 6 echo 'Testing...' 7 } 8 stage('Deploy') { 9 echo 'Deploying...' 10 } 11}
Both syntaxes support pipeline-as-code via a Jenkinsfile
stored in a Git repository, which keeps your pipeline definition under source control.
“I’ve just shared a detailed guide on setting up a CI/CD pipeline using Jenkins and Docker, and it’s helping developers automate deployments with ease.”
— Shahid Shaikh, via LinkedIn
To set up a basic CI CD pipeline, follow these steps:
Go to the Jenkins web UI.
Click "New Item", name it, and select Pipeline.
Use a text file named Jenkinsfile
in your project root with this sample pipeline code:
1pipeline { 2 agent any 3 environment { 4 ENV = 'staging' 5 } 6 stages { 7 stage('Checkout') { 8 steps { 9 git '<https://github.com/example/repo.git>' 10 } 11 } 12 stage('Build') { 13 steps { 14 sh 'mvn clean package' 15 echo 'Building...' 16 } 17 } 18 stage('Test') { 19 steps { 20 echo 'Testing...' 21 sh 'mvn test' 22 } 23 } 24 stage('Deploy') { 25 steps { 26 echo 'Deploying...' 27 sh 'scp target/app.war user@server:/path/to/tomcat/webapps' 28 } 29 } 30 } 31}
Click Build Now.
Track progress in console output or Jenkins dashboard.
Let’s see a delivery pipeline example using:
Git repository for source code.
Maven for building.
SonarQube for code analysis.
Nexus for artifact storage.
Apache Tomcat for deployment.
1pipeline { 2 agent any 3 stages { 4 stage('Checkout') { 5 steps { 6 git 'https://github.com/your-org/project.git' 7 } 8 } 9 stage('Build') { 10 steps { 11 sh 'mvn clean package' 12 echo 'Echo building project' 13 } 14 } 15 stage('SonarQube Analysis') { 16 steps { 17 withSonarQubeEnv('SonarQube') { 18 sh 'mvn sonar:sonar' 19 } 20 } 21 } 22 stage('Upload to Nexus') { 23 steps { 24 nexusArtifactUploader(...) 25 } 26 } 27 stage('Deploy to Tomcat') { 28 steps { 29 echo 'Echo deploying to Tomcat' 30 } 31 } 32 } 33}
This pipeline shows real-world integration of continuous delivery pipelines, leveraging the power of Jenkins and popular DevOps tools.
Use a multibranch pipeline for managing multiple branches.
Store your Jenkinsfile in the same git repository as your code.
Handle test failures and show results via junit
reports.
Use conditional logic for environment-specific deployments.
Always define environment variables securely.
Use the pipeline syntax generator from the Jenkins UI for help.
Clean up the Jenkins home directory periodically to free space.
Monitor previous run failed statuses and handle them gracefully.
Feature | Declarative Pipeline | Scripted Pipeline |
---|---|---|
Syntax | Simple, structured | Flexible, Groovy-based |
Use Case | Most common | Advanced logic |
Learning Curve | Beginner-friendly | Steeper |
Error Handling | Built-in | Manual |
Example Users | Beginners, teams | Advanced DevOps teams |
The Jenkins CI/CD pipeline transforms how software teams handle integration, testing, and deployment. By automating repetitive tasks , maintaining consistency across environments, and integrating seamlessly with essential tools, Jenkins eliminates the delays and errors of manual workflows. Whether you're using declarative pipeline syntax for clarity or scripted pipeline logic for flexibility, this approach streamlines your software delivery process from commit to production.
As release cycles shorten and expectations increase, mastering Jenkins is no longer optional; it’s a strategic necessity. It enables you to adapt quickly, deliver quality software faster, and scale your DevOps practices efficiently.
Start building your first pipeline, refine your workflows, and take control of your CI CD pipeline today. The path to reliable, automated delivery starts here.