Hargun SE Exp-09
Hargun SE Exp-09
EXPERIMENT NO. 10
LO: To be familiarized with Jenkins, which is used to build & test software Applications &
Continuous integration in DevOps environment.
Theory:
To install Jenkins following software packages are required
1. GIT (git-scm.com)
2. Notepad++ (https://notepad-plus-plus.org/downloads/)
3. Latest Java development kit (JDK 8 or 11)
4. Jenkins
5. Apache Maven (Optional)
Jenkins
• Jenkins is an open source automation tool written in Java with plugins built for
Continuous Integration purpose.
• Jenkins is used to build and test your software projects continuously making it easier for
developers to integrate changes to the project, and making it easier for users to obtain a
fresh build.
• It also allows you to continuously deliver your software by integrating with a large
number of testing and deployment technologies.
• Jenkins is an open source automation server that has become a crucial component in the
likes of Kubernetes and GitOps.
• Jenkins includes a number of plugins to help the automation of building and deploying
your applications.
• With Jenkins, organizations can accelerate the software development process by
automating it.
• Jenkins manages and controls software delivery processes throughout the entire
lifecycle, including build, document, test, package, stage, deployment, static code
analysis and much more.
• Jenkins is distributed as a WAR archive and as installer packages for the major operating
systems.
• Jenkins is an open-source server that is written entirely in Java. It lets you execute a
series of actions to achieve the continuous integration.
Choose “Run as local system” option because the “local user” option is giving error
Select and test the port , recommended port is 8080
Click “Install”
Click “Finish”
Go to localhost port 8080. To unlock Jenkins, go to the specified url, copy the password from
the url and paste it in the textbox
Click “Install suggested plugins”
URL selection
Jenkins setup has been completed
Example1
Example 1.1
Deploying a Freestyle App in Jenkins
The Steps for deploying a simple free style project in Jenkins is as Follows.
Step 4: Write a Simple Shell command to print the text as Like given below.
Click on the first build “1” followed by the console output to view the final output.
Example 1.2
Now let us take the parameters through the files. So, create a new shell script file in
local directory.
Now first run the shell script locally with no parameter, one parameter and two
parameters. Now. Let us run it through Jenkins Shell. To change existing program,
click on configure option and then modify the script. <Here, change directory to the
path where you have stored your file. You can get the location by pwd command>
Example 1.3
Variation to the above program
Example 2
Running a Java Program under jenkins Step 1 : Write a java program and test it
locally
Step 2: Now create freestyle project “Example2” in Jenkins.
Step 3: Go to build option and change path to directory where you have stored java
file followed by compile and run program commands.
Step 4: Now if your build fails due to permission problem then give write permission
to directory underneath it.
Step 5: And remove the existing .class file from your current directory.
Now after doing this your build gets successful and results are obtained. The output
console is as follows:
Example 3
Parameterized Build
In this program we are going to see how to provide parameters during runtime to your
shell script or java program.
The steps to be followed are as follows:
Step 1: Create a free style project example3 by clicking on new item followed by
specifying project name and free style project.
Step 2 : Now under general menu, select option this project is parameterize.
Step 3: Now select, this project is parameterized, select string parameter and specify
parameter name as “num”
Step 4: Go to build option and write script as follows:
Step 5: Now, select build with parameter and specify num value in textbox, let’s say
10.
Step 6: Click on build followed by console output to see result. The Output of
program will be shown as below
The Output of program will be shown as below.
CONCLUSION :
With Jenkins, organizations can advance the software development process through
automation. Jenkins integrates development life-cycle processes of all kinds which
include building, documenting, testing, packaging, staging, deploying, static analysis and
plenty more. We have successfully installed and configured Jenkins on Windows.
REFERENCES:
John Ferguson Smart,”Jenkins, The Definitive Guide”, O'Reilly Publication.
Website References:
Jenkins slides_reordered - U.S. Census Bureau, Online . Available :
Jenkins slides_reordered - U.S. Census Bureauhttps://www.census.gov › fedcasic › ppt