0% found this document useful (0 votes)
37 views

Jenkins Lab

Jenkins is a tool that allows for continuous integration by automatically building and testing code changes. It can be installed on a server and configured with jobs that trigger builds and tests whenever code is committed. Jenkins uses a master-slave architecture to distribute builds across different environments for testing purposes.

Uploaded by

Mukesh Gilda
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Jenkins Lab

Jenkins is a tool that allows for continuous integration by automatically building and testing code changes. It can be installed on a server and configured with jobs that trigger builds and tests whenever code is committed. Jenkins uses a master-slave architecture to distribute builds across different environments for testing purposes.

Uploaded by

Mukesh Gilda
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Jenkins?

Jenkins is a software that allows continuous integration. Jenkins will be installed on a server
where the central build will take place. The following flowchart demonstrates a very simple
workflow of how Jenkins works.

Along with Jenkins, sometimes, one might also see the association of Hudson. Hudson is a
very popular open-source Java-based continuous integration tool developed by Sun
Microsystems which was later acquired by Oracle. After the acquisition of Sun by Oracle, a
fork was created from the Hudson source code, which brought about the introduction of
Jenkins.

What is Continuous Integration?


Continuous Integration is a development practice that requires developers to integrate code
into a shared repository at regular intervals. This concept was meant to remove the problem
of finding later occurrence of issues in the build lifecycle. Continuous integration requires the
developers to have frequent builds. The common practice is that whenever a code commit
occurs, a build should be triggered.

Continuous Integration is a process of integrating code changes from multiple


developers in a single project many times. The software is tested immediately
after a code commit. With each code commit, code is built and tested. If the test
is passed, the build is tested for deployment. If the deployment is successful, the
code is pushed to production.
This commit, build, test, and deploy is a continuous process and hence the
name continuous integration/deployment.

System Requirements

JDK JDK 1.5 or above

Memory 2 GB RAM (recommended)

Disk Space No minimum requirement. Note that since all builds will be
stored on the Jenkins machines, it has to be ensured that
sufficient disk space is available for build storage.

Operating System Version Jenkins can be installed on Windows, Ubuntu/Debian, Red


Hat/Fedora/CentOS, Mac OS X, openSUSE, FReeBSD,
OpenBSD, Gentoo.

Java Container The WAR file can be run in any container that supports
Servlet 2.4/JSP 2.0 or later.(An example is Tomcat 5).
Advantages of using Jenkins
 Jenkins is being managed by the community which is very open. Every
month, they hold public meetings and take inputs from the public for the
development of Jenkins project.
 So far around 280 tickets are closed, and the project publishes stable
release every three months.
 As technology grows, so does Jenkins. So far Jenkins has around 320
plugins published in its plugins database. With plugins, Jenkins becomes
even more powerful and feature rich.
 Jenkins tool also supports cloud-based architecture so that you can
deploy Jenkins in cloud-based platforms.
 The reason why Jenkins became popular is that it was created by a
developer for developers.

Disadvantages of using Jenkins


Though Jenkins is a very powerful tool, it has its flaws.

 Its interface is out dated and not user friendly compared to current UI
trends.
 Though Jenkins is loved by many developers, it’s not that easy to
maintain it because Jenkins runs on a server and requires some skills as
server administrator to monitor its activity.
 One of the reasons why many people don’t implement Jenkins is due to
its difficulty in installing and configuring Jenkins.
 Continuous integrations regularly break due to some small setting
changes. Continuous integration will be paused and therefore requires
some developer attention.
 JENKINS INSTALLATION PROCESS :

Explore the Jenkins Environment


 Explore the Jenkins Environment

: • Once the Jenkins environment is set up, you can explore the various features and functionalities
available in the web interface.

• Jenkins has a rich user interface that provides access to features such as build history, build
statistics, and system information. These are the basic steps to install and set up Jenkins. Depending
on your use case, you may need to customize your Jenkins environment further. For example, you
may need to configure build agents, set up build pipelines, or integrate with other tools. However,
these steps should give you a good starting point for using Jenkins for CI/CD in your software
development projects.


 Jenkins provides a user-friendly web interface for managing
projects and jobs. Here are some of the key features of the
Jenkins environment:

 Dashboard: The Jenkins dashboard provides an overview of
all the projects and jobs currently running.

 Jobs: Jobs are the basic building blocks of Jenkins, and they
define a sequence of steps to be executed.

 Build history: Jenkins keeps track of the build history for
each job, which can be useful for tracking changes and
identifying issues.

 Plugins: Jenkins has a large collection of plugins that can be
used to extend its functionality, such as integrating with other
tools and services.

 Configuration: Jenkins provides a configuration interface
where you can set up projects, jobs, and build environments.

 By exploring these features and customizing the Jenkins
environment to your needs, you can create a powerful and
flexible CI/CD system for your projects.

Jenkins Architecture
Let us have a look at the Jenkins Architecture below diagram depicts the same.
This single Jenkins server was not enough to meet certain requirements like:

 Sometimes you might need several different environments to test your


builds. This cannot be done by a single Jenkins server.
 If larger and heavier projects get built on a regular basis then a single
Jenkins server cannot simply handle the entire load.

To address the above-stated needs, Jenkins distributed architecture came into


the picture.

Jenkins Distributed Architecture


Jenkins uses a Master-Slave architecture to manage distributed builds. In this
architecture, Master and Slave communicate through TCP/IP protocol.
DevOps Ccation Training Course

Explore Curriculum

Jenkins Master

Your main Jenkins server is the Master. The Master’s job is to handle:

 Scheduling build jobs.


 Dispatching builds to the slaves for the actual execution.
 Monitor the slaves (possibly taking them online and offline as required).
 Recording and presenting the build results.
 A Master instance of Jenkins can also execute build jobs directly.

Jenkins Slave
A Slave is a Java executable that runs on a remote machine. Following are the
characteristics of Jenkins Slaves:

 It hears requests from the Jenkins Master instance.


 Slaves can run on a variety of operating systems.
 The job of a Slave is to do as they are told to, which involves executing
build jobs dispatched by the Master.
 You can configure a project to always run on a particular Slave machine or
a particular type of Slave machine, or simply let Jenkins pick the next
available Slave.

The diagram below is self-explanatory. It consists of a Jenkins Master which is


managing three Jenkins Slave.
How Jenkins Master and Slave Architecture
works?
Now let us look at an example in which we use Jenkins for testing in different
environments like Ubuntu, MAC, Windows, etc.

The diagram below represents the same:

The above image represents the following functions:

 Jenkins checks the Git repository at periodic intervals for any changes
made in the source code.
 Each builds requires a different testing environment which is not possible
for a single Jenkins server. In order to perform testing in different
environments, Jenkins uses various Slaves as shown in the diagram.
 Jenkins Master requests these Slaves to perform testing and to generate
test reports.

How to setup Jenkins Master and Slaves?


1. Go to the Manage Jenkins section and scroll down to the section of

Manage Nodes.

2. Click on New Node


3. Give a name for the node, choose the Permanent Agent option and click on Ok.

4. Enter the details of the node slave machine. Here no. of executers in nothing but no. of
jobs that this slave can run parallely. Here we have kept it to 2. The Labels for which the
name is entered as “Slave1” is what can be used to configure jobs to use this slave
machine.Select Usage to Use this node as much as possible. For launch method we select
the option of “Launch agent by connecting it to the master”. If this option is not visible then
go to Jenkins home page -> Manage Jenkins -> Configure Global Security. Here in the
Agents section click on Random and Save it. Now you will find the required option.
Enter Custom WorkDir path as the workspace of your slave node. In Availability select
“Keep this agent online as much as possible”.Click on Save.
Once you complete the above steps, the new node machine will initially be in an offline state
but will come online if all the settings in the previous screen were entered correctly. One can
at any time make the node slave machine offline if required.

5. Now since your slave is up and running, lets execute a job on slave.

Demonstrate continuous integration and development using Jenkins.

DESCRIPTION Continuous Integration (CI) and Continuous Development (CD) are


important practices in software development that can be achieved usingJenkins. Here's an
example of how you can demonstrate CI/CD using Jenkins:

Create a simple Java application:

• Create a simple Java application that you want to integrate with Jenkins.

• The application should have some basic functionality, such as printing "Hello World" or
performing simple calculations. Commit the code to a Git repository:

• Create a Git repository for the application and commit the code to the repository.

• Make sure that the Git repository is accessible from the Jenkins server.

Create a Jenkins job:

• Log in to the Jenkins web interface and create a new job.

• Configure the job to build the Java application from the Git repository.

• Specify the build triggers, such as building after every commit to the repository.

Build the application:

• Trigger a build of the application using the Jenkins job.


• The build should compile the code, run any tests, and produce an executable jar file.

Monitor the build:

• Monitor the build progress in the Jenkins web interface.

The build should show the build log, test results, and the status of the build.

Deploy the application:

• If the build is successful, configure the Jenkins job to deploy the application to a production
environment.

• The deployment could be as simple as copying the jar file to a production server or using a
more sophisticated deployment process, such as using a containerization technology like
Docker.

Repeat the process:

• Repeat the process for subsequent changes to the application.

• Jenkins should automatically build and deploy the changes to the production environment.
This is a basic example of how you can use Jenkins to demonstrate CI/CD in software
development. In a real-world scenario, you would likely have more complex requirements,
such as multiple environments, different types of tests, and a more sophisticated deployment
process. However, this example should give you a good starting point for using Jenkins for
CI/CD in your software development projects.

CREATE A JOB :

You might also like