This document discusses Jenkins, an open source automation server that can be used to automate tasks related to building, testing, and deploying software. It describes how Jenkins can be installed via native packages, Docker, or by running its Java files. The document also explains what a Jenkins pipeline is and provides examples of declarative and scripted pipeline syntax to define build, test, and deploy stages. Finally, it discusses concepts like nodes, stages, and steps that are used in continuous development with Jenkins.
1. HOPE FOUNDATION’S
INTERNATIONAL INSTITUTE OF INFORMATION TECHNOLOGY, (I²IT)
www.isquareit.edu.in
+91 20 22933441 / 2
Hope Foundation’s International Institute of Information Technology, I²IT, P-14, Hinjawadi, Pune - 411 057
Jenkins
Prepared By
Prof. Mukesh More
2. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
● What is Jenkins?
● Jenkins Use?
● Installing Jenkins using Yum
● Installing Jenkins using Jenkins War File
● What is a Jenkins Pipeline?
● Continuous Development Scenario
● Pipeline concepts
● Declarative Pipeline Fundamentals
● Scripted Pipeline Fundamentals
● References
3. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
• Jenkins is
• a self-contained,
• open source automation server which can be used to automate
all sorts of tasks related to building, testing, and delivering or
deploying software.
• Jenkins can be installed through
• native system packages,
• Docker
• run standalone by any machine
• a Java Runtime Environment (JRE) installed.
4. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
● Immediate feedback on broken builds
● No building from dev machines and manually copying files
● Automated deployment
● Automated test execution and feedback
5. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Installing Jenkins using Yum
cd /
yum update –y
yum install java-1.8.0-openjdk-devel.x86_64 –y
sudo wget -o /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-
stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
amazon-linux-extras install epel –y
sudo yum install jenkins
systemctl start jenkins
systemctl status jenkins
6. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Installing Jenkins using Jenkins War File
cd /
yum update –y
yum install java-1.8.0-openjdk-devel.x86_64 –y
mkdir server
cd server
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.62/bin/apache-tomcat-
9.0.62.zip
ls –ltr
unzip apache-tomcat-9.0.62.zip
ls –ltr
7. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Installing Jenkins using Jenkins War File
Install Tomcat and Change Directory to apache-tomcat-9.2.62
cd apache-tomcat-9.2.62
cd webapps
To Download Jenkins War File
wget https://get.jenkins.io/war-stable/2.332.2/jenkins.war
ls –ltr
cd ..
ls -ltr
cd bin
ls -ltr
chmod –R 744 *
ls -ltr
./startup.sh
To get Admin Password
cat /root/.jenkins/secrets/initailAdminPassword
8. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
What is a Jenkins Pipeline?
• Jenkins Pipeline is a suite of plugins which supports implementing and
integrating continuous delivery pipelines into Jenkins.
• A continuous delivery pipeline is an automated expression of your process for getting
software from version control right through to your users and customers.
•Jenkins Pipeline provides an extensible set of tools for modeling simple-to-complex
delivery pipelines "as code".
•The definition of a Jenkins Pipeline is typically written into a text file (called
a Jenkinsfile) which in turn is checked into a project’s source control repository.
9. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Continuous Development Scenario
Fig. 1 CD scenario easily modelled in Jenkins Pipeline
10. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Pipeline concepts
Pipeline :
A Pipeline is a user-defined model of a CD pipeline. A Pipeline’s code defines your
entire build process, which typically includes stages for building an application, testing it
and then delivering it.
Node :
A node is a machine which is part of the Jenkins environment and is capable of
executing a Pipeline.
Stage :
A stage block defines a conceptually distinct subset of tasks performed through the
entire Pipeline (e.g. "Build", "Test" and "Deploy" stages), which is used by many
plugins to visualize or present Jenkins Pipeline status/progress.
Step :
A single task. Fundamentally, a step tells Jenkins what to do at a particular point in time
(or "step" in the process).
11. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Declarative Pipeline Fundamentals
Jenkinsfile (Declarative Pipeline)
pipeline
{ agent any stages
{ stage('Build')
{ steps { // }
} stage('Test')
{ steps { // }
} stage('Deploy')
{ steps{ // }
} } }
Execute this Pipeline or any of its stages, on any available agent.
Defines the "Build" stage.
Perform some steps related to the "Build" stage.
Defines the "Test" stage.
Perform some steps related to the "Test" stage.
Defines the "Deploy" stage.
Perform some steps related to the "Deploy" stage.
12. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
Scripted Pipeline Fundamentals
In Scripted Pipeline syntax, one or more node blocks do the core work throughout the
entire Pipeline.
Jenkinsfile (Scripted Pipeline)
node
{ stage('Build') { // }
stage('Test') { // }
stage('Deploy') { // }
}
Execute this Pipeline or any of its stages, on any available agent.
Defines the "Build" stage. stage blocks are optional in Scripted Pipeline syntax.
However, implementing stage blocks in a Scripted Pipeline provides clearer
visualization of each `stage’s subset of tasks/steps in the Jenkins UI.
Perform some steps related to the "Build" stage.
Defines the "Test" stage.
Perform some steps related to the "Test" stage.
Defines the "Deploy" stage.
Perform some steps related to the "Deploy" stage.
13. Hope Foundation’s International Institute of Information Technology, I²IT, P-14 Rajiv Gandhi Infotech Park, Hinjawadi, Pune - 411 057
[1] https://www.jenkins.io/doc/book/installing/
[2] https://www.jenkins.io/doc/book/installing/war-file/
[3] https://www.jenkins.io/doc/book/installing/windows/
[4] https://www.jenkins.io/doc/book/using/using-credentials/
[5] https://www.jenkins.io/doc/book/pipeline/
[6] https://www.jenkins.io/doc/book/pipeline/jenkinsfile/
[7] https://www.jenkins.io/doc/book/pipeline/running-pipelines/
[8] https://www.jenkins.io/doc/book/pipeline/syntax/
14. Thank You
For further information please contact
Prof. Mukesh More
Department of Computer Engineering
Hope Foundation’s International Institute of Information Technology, I²IT
Hinjawadi, Pune – 411 057
Phone - +91 20 22933441/9284960835
www.isquareit.edu.in | mukeshm@isquareit.edu.in