Software Training Institute in Chennai with 100% Placements – SLA Institute

Easy way to IT Job

Share on your Social Media

Jenkins Continuous Integration Tutorial: From Setup to Automation

Published On: May 15, 2025

Learning Jenkins is still a wise investment if you want to work in DevOps, particularly for positions in companies with a Jenkins infrastructure and for comprehending the principles of CI/CD. Jenkins job posts have reportedly increased, which suggests that demand is still high. So, get the fundamental understanding with this Jenkins continuous integration tutorial. Explore our DevOps course syllabus to get started.

Introduction to Continuous Integration and Jenkins Basics

The increasing use of Jenkins Pipeline underscores its significance in CI/CD automation.

What is Continuous Integration?

As part of the software development process known as continuous integration (CI), developers routinely merge their code updates into a common repository, following which automated builds and tests are conducted. 

CI’s main objectives are to decrease the time required to validate and release new software updates, enhance software quality, and identify and fix defects more quickly.

Benefits of CI:

For development teams and the software development process as a whole, implementing continuous integration has several advantages:

  • Early Bug Detection
  • Improved Code Quality
  • Reduced Integration Problems
  • Faster Feedback Loop
  • Increased Team Collaboration
  • Faster Release Cycles
  • Improved Developer Productivity
  • More Reliable Releases
  • Reduced Risk
  • Better Visibility

A key technique for contemporary software development is continuous integration, which enables teams to produce better software more quickly and effectively.

Introduction to Jenkins

One popular open-source automation server is Jenkins. It is mainly used to automate the software development lifecycle, which includes creating, testing, and deploying applications. It is written in Java. Imagine it as the main hub that coordinates all of the different tasks needed to get your code from development to production.

Jenkins uses the idea of pipelines, user-defined workflows made up of steps and stages, to do this. According to the “Pipeline-as-Code” concept, these pipelines, which are frequently specified in a Jenkinsfile, can be version-controlled alongside your application code.

Why is Jenkins Used?

Jenkins is popular for various reasons:

  • Automation of Repetitive Tasks: By automating the build, test, and deployment processes, it minimizes human errors.
  • Continuous Integration and Continuous Delivery (CI/CD): Teams can automate testing, integrate code changes more frequently, and distribute software updates more quickly with CI/CD.
  • Extensive Plugin Ecosystem: It can interface with almost any tool in the software development environment because to its extensive plugin library, which includes cloud platforms (AWS, Azure, and GCP), testing frameworks, notification systems, Git, Maven, Docker, and Kubernetes.
  • Free & Open Source: Because it is free and open-source, anyone can use it.
  • Platform Independent: Jenkins is available with Windows, Linux, and macOS asit is a Java-based program.
  • Scalability: Jenkins can manage big projects and teams because it uses a master-agent architecture to support distributed builds. 

Recommended: DevOps Online Course Program.

Jenkins Architecture

Here is the comprehensive components of Jenkins architecture:

Jenkins Master / Jenkins Controller

This is the central brain of the Jenkins setup. It’s responsible for:

  • Scheduling Build Jobs: Choosing when and where to perform build jobs.
  • Dispatching Builds to Agents: Assigning work to available agents.
  • Monitoring Agent: Keeping tabs on their online and offline status.
  • Recording and Presenting Build Results: Supplying reports, logs, and status.
  • Serving the Jenkins UI: The online interface you use to interact with Jenkins.
  • Managing Plugins: It includes handling updates, configuration, and installation.
  • Storing Configuration: Monitoring users, jobs, and system parameters.

Although build jobs can be carried out by the controller itself, it is usually advised to delegate the actual build work to agents for scalability and performance reasons.

Jenkins Agents / Jenkins Slaves

These worker nodes carry out the build jobs that the controller sends out.

Agents may have diverse hardware setups, installed software, and run on a variety of operating systems, including Linux, Windows, and macOS.

Key Characteristics of Agents:
  • They listen to what the Jenkins controller has to say.
  • They carry out the duties that are delegated to them, such as running tests and compiling code.
  • They return the findings to the controller.

Based on labels, you can set up certain projects to run consistently on a specific agent or agent type.

Agents may be configured as:
  • Static Agents: They are always-available, permanently configured computers.
  • Dynamic/Cloud Agents: AWS EC2, Docker, and Kubernetes are examples of dynamic/cloud agents that are provisioned on-demand when a build is required and may be stopped afterwards, providing improved resource utilization.

Communication

  • Protocols like TCP/IP are used for communication between the controller and agents.
  • The controller typically creates an SSH connection with the agent when it is launched over SSH. 
  • Other approaches exist as well, such as the Java Web Start (JNLP) agent.

Plugins

Jenkins’ extensive plugin ecosystem allows for a high degree of extensibility in its functionality. 

  • Plugins offer integrations with a range of services, tools, and technologies, including:
    • Version control systems (Git, SVN)
    • Build tools (Maven, Gradle)
    • Testing frameworks (JUnit, TestNG)
    • Cloud platforms (AWS, Azure, GCP)
    • Containerization technologies (Docker, Kubernetes)
    • Notification systems (Email, Slack)
    • Static analysis tools (SonarQube)
  • Jenkins may be tailored to your unique development environment and process with the help of plugins.

The Jenkins design is centered on distributed agents that carry out the actual work and a central controller that coordinates and oversees the CI/CD process. The vast ecosystem of plugins makes it possible to integrate with a variety of development tools with ease. Jenkins is incredibly scalable, flexible, and responsive to the demands of various projects for its design.

Suggested: Docker Course Online Program.

Jenkins Installation and Setup

Here is a short overview of Jenkins installation and configuration:

Prerequisites: Make sure your computer has the Java Development Kit (JDK) installed. Java is necessary for Jenkins to function.

Download Jenkins: 

Download the relevant package for your operating system (e.g., WAR file, native package for Linux, macOS, Windows) from the official Jenkins website (https://www.jenkins.io/download/).

Installation:

WAR file: If you downloaded the WAR file, you can use the following command to launch it in your Java runtime environment:

java -jar jenkins.war –httpPort=8080

Jenkins will normally start on port 8080 as a result.

Native Package: If a native package (such as a.deb or.rpm) was obtained, install it according to your operating system’s specific instructions. Typically, a package manager (such as apt or yum) is used for this.

Initial Setup:
  • After Jenkins has finished running, launch a web browser and go to the designated port, which is often http://localhost:8080.
  • An initial administrator password will be asked of you. Usually, your server’s log file contains this password (the path will be shown on the setup screen).
  • You will then be prompted to install recommended plugins or choose which plugins to install. For common CI/CD tasks, the recommended plugins are an excellent place to start.
  • Lastly, the first administrator user creation prompt will appear.
Access Jenkins: 

Once everything is set up, you can begin using Jenkins by logging in with the administrator credentials you generated.

It’s a high-level summary. Depending on your operating system and the installation method you select, the precise steps may differ significantly.

Recommended: Git training in Chennai.

Basic Jenkins Configuration

Let’s explore some fundamental Jenkins configurations that you should set up as soon as possible because you’ll probably meet them:

Accessing the Configuration Pages

Configuration settings are usually located under “Manage Jenkins” on the left-hand sidebar once you’re logged into Jenkins.

System Configuration

Select System under Manage Jenkins.

Here, you can set up:

  • Jenkins Location: Configure the Jenkins URL, which is necessary for additional integrations and email notifications.
  • System Message: Show a message to every user on the Jenkins dashboard.
  • Usage Statistics: Set up whether to provide the Jenkins project with anonymous usage data.
  • Node Properties: Set up environment variables that every task will have access to.
Global Tool Configuration

Go to Manage Jenkins > Global Tool Configuration.

Here, you can set up the locations for or oversee the installs of any build tools your projects may require, including:

  • JDK: Indicate which installations of Java should be used to create Java projects. Jenkins can install one for you automatically or you may point to an existing installation.
  • Maven/Gradle: Set up the installations of Maven and Gradle. Once more, you have the option of using pre-existing installations or letting Jenkins handle them.
  • Git: Jenkins often identifies Git automatically, but if necessary, you can specify a specific Git executable.
Manage Users

Go to Manage Jenkins > Manage Users.

This is where you can:

  • Create new user profiles.
  • Remove users.
  • Change user data, such as email address and complete name.
Configure Global Security

Go to Manage Jenkins > Configure Global Security.

This step is crucial to protecting your Jenkins instance. You can set up:

  • Authorization: Specify who can access Jenkins and what they can do (e.g., “Logged-in users can do anything” or “Anyone can do anything”, which is generally not advised for production, or more granular role-based access control with plugins).
  • Security Realm: Set up user authentication (e.g., LDAP, SAML, Jenkins’ own user database).
  • Prevent Cross Site Request Forgery exploits.
Manage Plugins

Go to Manage Jenkins > Manage Plugins.

In this section, you can:

  • View the installed plugins.
  • Verify whether the installed plugins have been updated.
  • From the Jenkins plugin repository, select and install new plugins.
  • Uninstall Plugins.

Basic Workflow After Initial Setup:

  • Configure Global Tools: Set up your JDK, Maven/Gradle, and other global tools.
  • Secure Jenkins: Set up authorization and authentication.
  • Install Necessary Plugins: Include plugins for your build tools, notification systems, version control system, etc.
  • Create Users (if needed): Create accounts for each member of your team.

When setting up Jenkins, you’ll probably need to complete these basic configuration steps.

Hone your skills with Nagios course in Chennai.

Creating Your First Jenkins Job/Project

Lets try an example of “Freestyle project” to create our first Jenkins project:

Step 1: Go to the Jenkins Dashboard: 

You should see the main dashboard after logging into Jenkins.

Step 2: Create a New Item:

Look for the “New Item” or “Create a job” link in the left-hand sidebar. Press it.

Step 3: Enter an Item Name:

The prompt to “Enter an item name” will appear. Give your project a name that describes it, such as “my first job.”

Step 4: Choose a Project Type:
  • A list of project types will appear. Select the “Freestyle project” option for this example.
  • At the bottom, click the “OK” button.
Step 5: Configure Your Project: 

You will now be sent to your new job’s configuration page. There are multiple sections on this page:

General:

  • You can give your project a description.
  • “Discard old builds” is one of the choices you may encounter to control how many build histories Jenkins retains.

Source Code Management:

This is where you would set up your project’s code if it is in a version control system like Git. 

  • If we’re not pulling code from somewhere, we might be able to skip this step for this first easy task. 
  • You can choose “Git” and type in a “Repository URL” (such as a straightforward public project on GitHub) to try pulling from a public Git repository.

Build Triggers:

When Jenkins should execute this job is specified in this section. “No triggers” (the build needs to be started manually) is a common trigger.

  • “Poll SCM” (Jenkins periodically scans your source code repository for updates). 
  • “Build Periodically” (Jenkins uses cron syntax to execute the job on a specified schedule).

Build Environment:

It enables you to set environment variables and configure the environment for your build.

Build:

This is the main function of your employment. One or more “build steps” can be added. Select “Add build step” from the drop-down menu. Typical choices include:

  • Execute Shell: For executing batch tasks on Windows or shell commands on Linux and macOS. This should be our first job.
  • Invoke Top-Level Maven Targets: if a Maven project is being worked on.
  • Invoke Gradle Script: If Gradle is being used.

“Execute shell” is what we’ll choose. Enter a basic command in the “Command” text field that displays, such as:

echo “Hello from my first Jenkins job!”

date

Post-build Actions:

These are things like email alerts, artifact archiving, and starting other Jenkins jobs that take place following a successful (or unsuccessful) build.

Step 6: Save Your Configuration: 

Click the “Save” button at the bottom of the page after you’ve set up the desired parts.

Running Your First Job:

  • The main page of the project should now be visible to you.
  • Look for the “Build Now” button in the left-hand sidebar. Press it.

Observing the Build:

  • A new entry will show up in the project page’s “Build History” section. During the build, it will probably have a whirling icon.
  • The icon will change (for example, to a red ball for failure, or a blue ball for success) when the build is finished.
  • In the “Build History” section, click on the build number (for example, #1).
  • Click “Console Output” on the build page to view the output of your “Execute shell” command as well as other details about the build.

Well done! Your first Jenkins task has just been created and executed.

Learn testing automation for DevOps practices with our Selenium course in Chennai.

Working with Jenkins Pipelines

You can define your complete build, test, and deployment routine as code with pipelines, which is a valuable feature. This code, which makes your CI/CD process repeatable and allows version control, is usually kept in a file named Jenkinsfile in the repository for your project.

There are two main types of Pipeline syntax:

  • Declarative Pipeline: A more modern, organized syntax that makes defining pipelines easier and more prescriptive.
  • Groovy-based Scripted Pipeline: A more adaptable syntax that gives you more programmatic control, but it can also be more complicated.

Because of its structure and readability, the Declarative Pipeline is typically advised, therefore we’ll concentrate on it.

Basic Structure of a Declarative Pipeline

The top-level sections of a simple Declarative Pipeline are as follows:

Groovy

pipeline {

    agent any // Specifies where the pipeline will run

    stages {

        stage(‘Stage Name 1’) { // A logical grouping of steps

            steps {

                // One or more steps to be executed in this stage

                echo ‘This is step 1 in Stage 1’

            }

        }

        stage(‘Stage Name 2’) {

            steps {

                echo ‘This is step 1 in Stage 2’

            }

        }

    }

}

  • pipeline block: The top-level block that defines the pipeline as a whole.
  • agent: Indicates the execution location of the pipeline or particular stages. whatever available agent can operate it, by whatever means. To target particular agents, you can also specify labels.
  • stages: Consists of one or more blocks of stages. The pipeline is arranged into logical phases using stages (e.g., Build, Test, Deploy).
  • stage(‘Stage Name’): It provides a descriptive name for a stage.
  • steps: Consists of one or more blocks of stairs. Jenkins will actually carry out steps, such as checking out code, conducting tests, and running a build command.

Creating a Jenkins Pipeline Job

  1. Access the Jenkins Dashboard: Proceed to your Jenkins dashboard as previously.
  2. Click “New Item” to create a new item.
  3. Put the name of the item here: Name your pipeline (my-first-pipeline, for example).
  4. Select “Pipeline”: The “Pipeline” project type should be chosen.
  5. Press “OK.”
  6. Configure the Pipeline: The pipeline configuration page will be displayed to you. To access the “Pipeline” section, scroll below.
  7. Describe the pipeline: Here, you have a few choices:
  • Pipeline Script: Your pipeline script can be entered directly in the text field.
  • SCM Pipeline Script: Jenkins can be told to retrieve the Jenkins file from your source code management system (such as Git). The more popular and advised method is this one.

For a basic example, let’s try the “Pipeline script” option. The basic declarative pipeline structure from above should be copied and pasted into the text field:

pipeline {

    agent any

    stages {

        stage(‘Greeting’) {

            steps {

                echo ‘Hello from my first Jenkins Pipeline!’

            }

        }

        stage(‘Current Date’) {

            steps {

                sh ‘date’ // Execute a shell command

            }

        }

    }

}

  1. Save the Configuration: Click the “Save” button.

Running the Pipeline

  • You will be directed to the main page of the pipeline.
  • Press the “Build Now” selector.

Observing the Pipeline Execution

  • A build number will show up. Click on it.
  • The steps in your pipeline will be shown visually on the build’s page. To view the logs, click on each step.
  • To view the complete output of the pipeline run, click “Console Output”.

The “Current Date” stage should run the date command, and the “Greeting” stage should output “Hello from my first Jenkins Pipeline!”

Recommended: AWS DevOps Training Program.

Integrating with Version Control Systems (VCS)

Integrating Jenkins with VCS (like Git) allows Jenkins to automatically get your project’s code.

For Freestyle Projects:
  • Go to project Configuration.
  • In Source Code Management, select Git.
  • Enter the Repository URL.
  • Add Credentials if the repo is private.
  • Specify the Branch if needed.
For Pipeline Projects (using Jenkinsfile from SCM):
  • Go to project Configuration.
  • In the Pipeline section, choose “Pipeline script from SCM”.
  • Select Git as the SCM.
  • Enter the Repository URL.
  • Add Credentials if private.
  • Specify the Branch.
  • Jenkins will then fetch your code and run the pipeline defined in your Jenkinsfile.

Jenkins can also be set up to automatically trigger builds when changes are pushed to your repository (often using webhooks).

Build Automation with Jenkins

Using Jenkins to automatically carry out the procedures required to create your program whenever a trigger (such as a code commit or planned time) happens is known as build automation.

A Jenkins job or pipeline is configured to:

  1. Get the code (from VCS like Git).
  2. Compile the code (using tools like Maven, Gradle, Make).
  3. Run tests (unit, integration, etc.).
  4. Package the application (e.g., into a JAR, WAR, Docker image).

Jenkins provides logs and status updates while managing the execution of these tasks in accordance with your settings. This ensures that the build process is hands-off, dependable, and repeatable.

Explore all in-demand software training courses.

Conclusion

From setting up your first job to comprehending the foundations of pipelines, we have covered the essentials of continuous integration with Jenkins in this Jenkins Continuous Integration Tutorial. Jenkins can automate important processes like developing, testing, and even alerting your team, as you have seen. We urge you to keep trying new things and using these concepts in your own endeavors through our DevOps training in Chennai.

Share on your Social Media

Just a minute!

If you have any questions that you did not find answers for, our counsellors are here to answer them. You can get all your queries answered before deciding to join SLA and move your career forward.

We are excited to get started with you

Give us your information and we will arange for a free call (at your convenience) with one of our counsellors. You can get all your queries answered before deciding to join SLA and move your career forward.