0% found this document useful (0 votes)
30 views47 pages

Hargun SE Exp-09

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views47 pages

Hargun SE Exp-09

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

DEPARTMENT OF INFORMATION TECHNOLOGY

COURSE CODE: DJ19ITL602 CLASS: TY BTech

COURSE NAME: Software Engineering Laboratory SAPID: 60003210174

EXPERIMENT NO. 10

LO: To be familiarized with Jenkins, which is used to build & test software Applications &
Continuous integration in DevOps environment.

AIM / OBJECTIVE: Demonstration of working of CICD pipeline (Continuous Integration


and Continuous Deployment tools) e.g Jenkin.

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)

Step 1 Install GIT


Step 2 Install Notepad++
Step 3 Install Java
Step 4 Install Jenkins
Step 5 Install Maven

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.

Jenkins Installation Steps On Windows:

Download the package and click install


Select destination folder

Choose “Run as local system” option because the “local user” option is giving error
Select and test the port , recommended port is 8080

Select jdk path


Click “Next”

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”

Packages are being installed


Welcome screen

URL selection
Jenkins setup has been completed

Homepage for first time users


Create a new project “exp2”
Login screen for subsequent sessions

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 1: Click on Create new jobs.


Step 2: Now specify the name to the project as “Example1”, select option “Free style
project” and then click on OK button.
Step 3: In this project we are going to learn how to run simple shell script on Jenkins.
So, Click on Build option select Execute script from dropdown menu.

Step 4: Write a Simple Shell command to print the text as Like given below.

Now click on the apply button followed by the save button.


Step 5: No Build a project to see the output Click on our first build “1” followed by
the console output to see the output.

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 : Select String parameter and specify name as “Fname”.


Step 4: Again, click on add parameter and select choice parameter Take second
parameter as choice box. Specify name as “City” and add the choices in each line
Step 5: Write a shell script that takes 2 parameters with command line arguments
name and city.
Step 6: Now, go back to jenkins, Selct Build option, give the path and write script as
shown below
Step 7 : Click on Build
Step 8 : Go to console to see the output

Example 4 Running a Java program in Jenkins Step


1: Write a program for multiplication.
Step 2: Delete class file and give write permission to program.
Step 3: Now create a new Jenkins freestyle project “Example4” for running the above
program.

Step 4: Select string parameter and name it as “num”.


Step 5: Go to build option and select execute shell. Write the commands with
changing path to directory where you have stored java program as below.
Step 6 : Now click on Save. Select build with parameter option and specify value of
“num” whose multiplication tables needs to be displayed.
Step 7 : Click on build to see the output as below

Example 5 Running a Python program in Jenkins Step


1: Write and test python3 program locally.
Step 2: Now create a new item followed by specifying name “example5” and select
freestyle project.

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy