Jenkins made simple

Jenkins Explained: A Step-by-Step Process to CI/CD

Jenkins is an open-source automation server that helps developers build, test, and deploy their software applications. It’s a powerful tool that automates the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery (CI/CD).

On This Page

Introduction to Jenkins

What is Jenkins?

Jenkins is a self-contained, Java-based automation server that contains hundreds of plugins to support building, deploying, and automating any project. Think of it as a digital assistant that helps developers streamline their workflow by automating repetitive tasks.

Why Use Jenkins?

There are several reasons why Jenkins has become so popular in the DevOps world:

  • Open-source and free: Jenkins is completely free to use and has a large community supporting it.
  • Platform-independent: Since it’s Java-based, Jenkins can run on any operating system.
  • Extensive plugin ecosystem: With over 1,800 plugins available, Jenkins can be customized to meet various needs.
  • Easy to install and configure: Getting started with Jenkins is straightforward, even for beginners.
  • Distributed builds: Jenkins can distribute work across multiple machines, helping to speed up the build process.

A Brief History of Jenkins

Jenkins was originally developed as the Hudson project by Kohsuke Kawaguchi in 2004. In 2011, a dispute with Oracle (who had acquired Sun Microsystems) led to a fork in the project. The majority of the community continued development under the new name “Jenkins.”

Since then, Jenkins has grown to become one of the most widely used CI/CD tools in the software development industry.

Understanding CI/CD

Before diving deeper into Jenkins, it’s essential to understand the concepts of Continuous Integration (CI) and Continuous Deployment/Delivery (CD).

What is Continuous Integration?

Continuous Integration (CI) is a development practice where developers frequently merge their code changes into a central repository. After each merge, an automated build and automated tests are run.

The main goals of CI include:

  • Detecting and fixing bugs quickly
  • Improving software quality
  • Reducing the time it takes to validate and release new software updates

What is Continuous Deployment/Delivery?

Continuous Deployment (CD) is the practice of automatically deploying every change that passes the automated tests to production.

Continuous Delivery is similar, but it requires manual approval before deploying to production.

Both practices aim to make the release process more efficient and less error-prone.

Why are CI/CD Important?

CI/CD practices help teams:

  • Deliver software faster and more frequently
  • Reduce manual errors in the deployment process
  • Improve code quality through automated testing
  • Get faster feedback on code changes
  • Reduce the time between writing code and running it in production

Jenkins Architecture

Understanding the architecture of Jenkins is crucial for effectively using it. Jenkins has a simple yet powerful architecture that consists of several key components.

Jenkins Master

The Jenkins Master (or Jenkins server) is the main Jenkins instance that:

  • Serves the web UI
  • Stores the configuration and job definitions
  • Handles HTTP requests
  • Manages the build environment

The Master can execute jobs directly, but it’s often recommended to distribute the workload to agents for better performance and scalability.

Jenkins Slave/Agent

A Jenkins Agent (formerly called a slave) is a machine that connects to the Jenkins Master and executes tasks as directed by the Master. Agents can be:

  • Physical machines
  • Virtual machines
  • Docker containers

Using agents allows you to:

  • Distribute the build workload
  • Run builds in different environments (e.g., different operating systems)
  • Isolate build environments for security

Jenkins Pipeline

A Jenkins Pipeline is a suite of plugins that supports implementing and integrating continuous delivery pipelines into Jenkins. It provides:

  • An extensible automation server for creating simple or complex delivery pipelines
  • A way to define your entire build process in code
  • Better visibility and traceability of the build process

Installing Jenkins

Getting Jenkins up and running is a straightforward process. Let’s walk through the installation steps for different platforms.

System Requirements

Before installing Jenkins, ensure your system meets the following minimum requirements:

ComponentMinimum RequirementRecommended
JavaJava 8Java 11 or newer
Memory256 MB1 GB or more
Disk Space1 GB10 GB or more
CPU1 core2 or more cores

Installation on Windows

To install Jenkins on Windows:

  1. Download the latest Jenkins Windows installer from the official Jenkins website.
  2. Run the installer as an administrator.
  3. Follow the installation wizard instructions.
  4. Once installed, Jenkins will start as a Windows service.
  5. Open your web browser and navigate to http://localhost:8080 to access Jenkins.

Installation on Linux (Ubuntu/Debian)

To install Jenkins on Ubuntu or Debian:

  1. Update your package index:
sudo apt-get update
  1. Install Java:
sudo apt-get install openjdk-11-jdk
  1. Add the Jenkins repository key:
wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -
  1. Add the Jenkins repository:
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
  1. Update the package index again:
sudo apt-get update
  1. Install Jenkins:
sudo apt-get install jenkins
  1. Start the Jenkins service:
sudo systemctl start jenkins
  1. Open your web browser and navigate to http://localhost:8080 to access Jenkins.

Installation on macOS

To install Jenkins on macOS using Homebrew:

  1. Install Homebrew if you haven’t already:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Install Jenkins:
brew install jenkins
  1. Start the Jenkins service:
brew services start jenkins
  1. Open your web browser and navigate to http://localhost:8080 to access Jenkins.

Initial Configuration

After installing Jenkins, you’ll need to complete the initial setup:

  1. Unlock Jenkins: When you first access Jenkins, you’ll see an “Unlock Jenkins” screen. You’ll need to retrieve the initial admin password from the file mentioned on the screen (usually located at /var/lib/jenkins/secrets/initialAdminPassword on Linux).
  2. Customize Jenkins: You can choose to install the suggested plugins or select specific plugins based on your needs.
  3. Create First Admin User: Set up your administrator account with a username and password.
  4. Instance Configuration: Configure the Jenkins URL for your instance.

Once these steps are completed, you’ll have a working Jenkins instance ready to use!

Jenkins Dashboard and Basic Concepts

The Jenkins dashboard is your main interface for managing Jenkins. Let’s explore its components and some basic Jenkins concepts.

Dashboard Overview

The Jenkins dashboard consists of several key areas:

  • Header: Contains the Jenkins logo, search box, and user menu.
  • Side Panel: Provides navigation to different sections like “New Item,” “People,” “Build History,” etc.
  • Main Area: Displays a list of your projects/jobs and their current status.

Jobs/Projects

In Jenkins, a job (or project) is a runnable task that’s controlled and monitored by Jenkins. There are several types of jobs:

  • Freestyle Project: A flexible job type that allows you to configure build steps, triggers, and post-build actions.
  • Pipeline: A job type that defines your entire build process in code.
  • Multi-configuration Project: A job type that can run the same build on different configurations (e.g., different operating systems or Java versions).
  • Folder: A way to organize jobs and projects hierarchically.

Builds

A build is an execution of a job. Each build has:

  • A unique build number
  • A status (Success, Failed, Unstable, Aborted, etc.)
  • Build logs
  • Artifacts (files generated during the build)
  • Test results

Plugins

Plugins extend Jenkins’ functionality. There are hundreds of plugins available for:

  • Source code management (Git, SVN, etc.)
  • Build tools (Maven, Gradle, etc.)
  • Notification (Email, Slack, etc.)
  • Authentication and security
  • And much more!

You can manage plugins through “Manage Jenkins” > “Manage Plugins.”

Creating Your First Jenkins Job

Now that we’re familiar with the Jenkins interface, let’s create our first job. We’ll start with a simple Freestyle Project.

Creating a Freestyle Project

  1. From the Jenkins dashboard, click “New Item” in the left-hand menu.
  2. Enter a name for your project (e.g., “My First Job”).
  3. Select “Freestyle Project” and click “OK.”

Configuring Source Code Management

If your project is stored in a version control system like Git, you’ll need to configure the source code management:

  1. Scroll down to the “Source Code Management” section.
  2. Select your version control system (e.g., Git).
  3. Enter the repository URL (e.g., https://github.com/username/repo.git).
  4. If it’s a private repository, you’ll need to add credentials.

Setting Up Build Triggers

Build triggers determine when your job should run automatically. Common options include:

  • Build periodically: Schedule builds at specific times using cron syntax.
  • Poll SCM: Jenkins will check for changes in your repository at regular intervals.
  • Build after other projects are built: Trigger this job after another job completes successfully.
  • Trigger builds remotely: Allow external systems to trigger builds via a URL.

For our example, let’s select “Poll SCM” and enter H/5 * * * * to check for changes every 5 minutes.

Configuring Build Steps

Build steps define what actions Jenkins should perform during the build. For a simple project:

  1. Scroll down to the “Build” section.
  2. Click “Add build step” and select “Execute shell” (on Linux/macOS) or “Execute Windows batch command” (on Windows).
  3. Enter the commands you want to run. For example:
echo "Starting build..."
ls -la
echo "Build completed!"

Setting Up Post-Build Actions

Post-build actions define what happens after the build completes. Common options include:

  • Archive the artifacts: Save files generated during the build.
  • Publish JUnit test result report: Display test results.
  • E-mail Notification: Send email notifications based on build status.
  • Deploy to container: Deploy applications to servers.

For our example, let’s add an “E-mail Notification”:

  1. Scroll down to “Post-build Actions.”
  2. Click “Add post-build action” and select “E-mail Notification.”
  3. Enter the email addresses to notify, separated by spaces.

Saving and Running Your Job

  1. Click “Save” to save your job configuration.
  2. To run the job immediately, click “Build Now” in the left-hand menu.
  3. Click on the build number in the “Build History” to view the build details and console output.

Congratulations! You’ve created and run your first Jenkins job!

Jenkins Pipeline

While Freestyle projects are great for simple tasks, Jenkins Pipeline offers a more powerful and flexible way to define your build process. Let’s explore how to create a pipeline.

What is a Pipeline?

A Pipeline is a user-defined model of a continuous delivery (CD) pipeline. It defines your entire build process in code, which is stored in a text file called a Jenkinsfile.

Using pipelines has several advantages:

  • Code: Pipelines are defined in code, making them easy to review, version, and modify.
  • Durable: Pipelines can survive Jenkins restarts.
  • Pausable: Pipelines can be stopped and resumed.
  • Versatile: Pipelines support complex real-world CD requirements.
  • Extensible: Pipeline plugins can be easily extended to support new capabilities.

Declarative vs. Scripted Pipeline

There are two types of Jenkins Pipeline syntax:

  1. Declarative Pipeline: A newer, more structured approach with a predefined hierarchy.
  2. Scripted Pipeline: A more flexible approach using Groovy code.

For beginners, Declarative Pipeline is recommended as it’s more straightforward and has a simpler structure.

Pipeline Syntax

A Declarative Pipeline follows a specific structure:

pipeline {
    agent any // Specifies where the pipeline will run
    stages {
        stage('Build') { // Defines a stage
            steps {
                // Steps to perform in this stage
            }
        }
        stage('Test') {
            steps {
                // Steps to perform in this stage
            }
        }
        stage('Deploy') {
            steps {
                // Steps to perform in this stage
            }
        }
    }
    post {
        always {
            // Actions to perform regardless of the stage outcome
        }
        success {
            // Actions to perform if all stages succeed
        }
        failure {
            // Actions to perform if any stage fails
        }
    }
}

Creating a Simple Pipeline

Let’s create a simple pipeline:

  1. From the Jenkins dashboard, click “New Item.”
  2. Enter a name for your pipeline (e.g., “My First Pipeline”).
  3. Select “Pipeline” and click “OK.”
  4. Scroll down to the “Pipeline” section.
  5. For “Definition,” select “Pipeline script.”
  6. Enter the following pipeline script:
pipeline {
    agent any

    stages {
        stage('Hello') {
            steps {
                echo 'Hello, world!'
            }
        }

        stage('Build') {
            steps {
                echo 'Building the application...'
                // Add your build commands here
            }
        }

        stage('Test') {
            steps {
                echo 'Running tests...'
                // Add your test commands here
            }
        }
    }

    post {
        always {
            echo 'Pipeline completed!'
        }
        success {
            echo 'Pipeline succeeded!'
        }
        failure {
            echo 'Pipeline failed!'
        }
    }
}
  1. Click “Save” to save your pipeline.
  2. Click “Build Now” to run the pipeline.

You can view the progress of each stage in the “Stage View” on the pipeline page.

Jenkins Plugins

Plugins extend Jenkins’ functionality, allowing you to customize it to your specific needs. Let’s explore some popular plugins and how to manage them.

Here are some of the most popular Jenkins plugins:

Plugin NameDescription
GitIntegrates Git with Jenkins
DockerAllows Jenkins to build and publish Docker images
Blue OceanProvides a modern, user-friendly UI for Jenkins
PipelineDefines continuous delivery pipelines in code
Credentials BindingAllows credentials to be bound to environment variables
Email ExtensionEnhances the email notification capabilities
Slack IntegrationSends build notifications to Slack channels
SonarQube ScannerIntegrates SonarQube code analysis with Jenkins
KubernetesProvides cloud-native continuous delivery with Kubernetes
Workspace CleanupCleans up the workspace before or after a build

Installing and Managing Plugins

To install and manage plugins:

  1. Go to “Manage Jenkins” > “Manage Plugins.”
  2. In the “Available” tab, you can search for plugins to install.
  3. Check the box next to the plugin(s) you want to install and click “Install without restart” or “Download now and install after restart.”
  4. In the “Installed” tab, you can view and manage installed plugins.
  5. In the “Updates” tab, you can check for and install plugin updates.

Useful Plugins for Beginners

If you’re new to Jenkins, here are some plugins you might find particularly useful:

  1. Blue Ocean: Provides a more intuitive and modern UI for Jenkins.
  2. Pipeline: Essential for creating and managing Jenkins pipelines.
  3. Git: If you’re using Git for version control, this plugin is a must-have.
  4. Email Extension: Enhances Jenkins’ email notification capabilities.
  5. Workspace Cleanup: Helps keep your build environment clean.

Best Practices for Jenkins

To get the most out of Jenkins, it’s important to follow best practices. Let’s cover some key areas.

Security Considerations

Security should be a top priority when using Jenkins. Here are some security best practices:

  • Use the latest version: Always keep Jenkins updated to the latest stable version to ensure you have the latest security patches.
  • Secure credentials: Use the Credentials plugin to store sensitive information securely.
  • Limit access: Configure user permissions carefully to ensure users only have access to what they need.
  • Use HTTPS: Configure Jenkins to use HTTPS to encrypt communication.
  • Regularly review plugins: Keep your plugins updated and remove any that you’re not using.

Performance Optimization

To ensure your Jenkins instance runs smoothly:

  • Allocate sufficient resources: Make sure Jenkins has enough memory and CPU resources.
  • Use agents: Distribute builds across multiple agents to reduce the load on the master.
  • Clean up old builds: Configure jobs to discard old builds to save disk space.
  • Monitor performance: Use the Monitoring plugin to keep an eye on Jenkins’ performance.

Backup and Recovery

To prevent data loss:

  • Regular backups: Regularly back up your Jenkins home directory.
  • Version control: Store your Jenkinsfiles in version control.
  • Document your setup: Keep documentation of your Jenkins configuration and job setups.
  • Test your recovery process: Regularly test your backup and recovery procedures.

WrapUP

In this tutorial, we’ve covered the basics of Jenkins, from understanding what it is and why it’s used, to installing it, creating jobs, and setting up pipelines. We’ve also explored plugins and best practices for using Jenkins effectively.

Jenkins is a powerful tool that can significantly improve your development workflow by automating repetitive tasks and enabling continuous integration and delivery. While we’ve covered the fundamentals, there’s still much more to learn as you start using Jenkins in real-world scenarios.

continuous testing with jenkins illustration

FAQs

What is Jenkins in the simplest terms?

Think of Jenkins as a helpful robot for your software projects. Instead of you manually building, testing, and deploying your code every time you make a change, you can teach Jenkins to do all of that for you automatically. It handles the boring, repetitive tasks so you can focus on writing great code.

Is Jenkins the only automation tool available?

No, Jenkins is not the only tool, but it is one of the most famous and widely used. Other tools like GitLab CI and GitHub Actions are also popular. Jenkins’ biggest strength is its massive library of add-ons (called plugins), which makes it incredibly flexible and customizable for almost any task you can imagine.

Do I need to be a programmer to use Jenkins?

Not necessarily! Jenkins is designed for everyone on a software team.
You can start with Freestyle projects, where you configure everything by pointing and clicking in a user-friendly interface, with no coding required.
As you get more advanced, you can use Jenkins Pipelines, which involve writing a simple script. This gives you more power and control, but it’s optional for getting started.

Is Jenkins really free?

Yes, Jenkins is completely free to download, install, and use. It’s an open-source project, which means a global community of developers contributes to it. The only “cost” is the time you spend setting it up and the computer resources (servers) you need to run it on

What’s the real difference between a Jenkins Master and an Agent?

Imagine a construction site.
The Jenkins Master is the site manager. It doesn’t do the heavy lifting itself. Instead, it looks at the blueprints (your jobs), decides what needs to be built, and tells the workers what to do.
The Jenkins Agents are the workers. They are the machines that actually perform the tasks assigned by the Master, like compiling code, running tests, and creating the final software package.

What exactly is a Jenkinsfile?

A Jenkinsfile is the recipe for your entire software process. It’s a simple text file that you keep alongside your source code. Inside this file, you write down all the steps Jenkins needs to follow, in order, such as:
Get the latest code from the repository.
Install necessary tools.
Run all the tests.
If tests pass, package the application.
Deploy the package to the server.

Where do I look if my Jenkins job fails?

Don’t panic, it happens to everyone! The first place to go is the Console Output.
Navigate to your project’s page in Jenkins.
Click on the failed build in the build history (it will usually be colored red).
On the next page, click on the Console Output link.

Can Jenkins actually deploy my code to a live server?

Yes, absolutely! This is one of its most powerful features and represents the “CD” (Continuous Deployment/Delivery) in CI/CD. Jenkins can be configured to automatically take your successfully built and tested code and deploy it to a web server, a cloud service, or any other environment. You just need to tell it how to do that using specific plugins and scripts.

Is Jenkins difficult to install and set up?

For a beginner, it’s surprisingly straightforward. The main requirement is that you must have Java installed on your system, since Jenkins is a Java-based application. Once Java is ready, the installation process involves just a few steps for your specific operating system (Windows, Mac, or Linux). The official documentation provides clear, easy-to-follow guides.

Vivek Kumar

Vivek Kumar

Full Stack Developer
Active since May 2025
26 Posts

Full-stack developer who loves building scalable and efficient web applications. I enjoy exploring new technologies, creating seamless user experiences, and writing clean, maintainable code that brings ideas to life.

You May Also Like

More From Author

4 1 vote
Would You Like to Rate US
Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments