SlideShare ist ein Scribd-Unternehmen logo
1 von 29
JENKINS’ MASTER AND SLAVE
ARCHITECTURE
@2020 copyright KalKey training
MASTER AND SLAVE
ARCHITECTURE
@2020 copyright KalKey training
INTRODUCTION OF JENKINSFILE
• A continuous delivery pipeline is an automated expression of your process for getting software from
version control right through to your users and customers.
@2020 copyright KalKey training
CREATING A JENKINSFILE
• The current Jenkinsfile has two ways of writing, and pipeline if it is the root, it is called Declarative
Pipeline. In this case, you cannot write the Groovy script directly, and if you want to write Groovy
you script need to use the directive.
• Pipeline If that does not start from, say Scripted Pipeline, to this case also write directly Groovy
script, node() arrow stage(), such as, can also be written Pipeline Steps method. Although it seems
convenient, degrees of freedom are too high and tend to be craftsmen code.
@2020 copyright KalKey training
JENKINS PIPELINE & COMPONENTS
• What is Jenkins Pipeline?
Jenkins Pipeline (or simply "Pipeline" with a capital "P") is a suite of plugins which supports
implementing and integrating continuous delivery pipelines into Jenkins.
• 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.
Also, a pipeline block is a key part of Declarative Pipeline syntax.
• Node
A node is a machine which is part of the Jenkins environment and is capable of executing a Pipeline.
Also, a node block is a key part of Scripted Pipeline syntax.
@2020 copyright KalKey training
CONT….
• 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). For example, to execute the shell command make use the sh step: sh 'make'. When a plugin
extends the Pipeline DSL, [1] that typically means the plugin has implemented a new step
@2020 copyright KalKey training
JENKINSFILE (DECLARATIVE PIPELINE)
pipeline {
agent any
stages {
stage('Build') {
steps {
echo "We are in Build Stage"
}
}
stage('Test') {
steps {
echo "We are in Test Stage"
}
}
stage('Deploy') {
steps {
echo "We are in Deploy Stage"
}
}
}
}
@2020 copyright KalKey training
JENKINSFILE (SCRIPTED PIPELINE)
node {
stage('Build') {
echo “Build stage”
}
stage('Test') {
echo “Test stage”
}
stage('Deploy') {
echo “Deploy stage”
}
}
@2020 copyright KalKey training
STRING INTERPOLATION
• Jenkins Pipeline uses rules identical to Groovy for string interpolation.
• While Groovy supports declaring a string with either single quotes, or double quotes
def username = 'Jenkins'
echo 'Hello Mr. ${username}'
echo "I said, Hello Mr. ${username}“
Result:
Hello Mr. Jenkins
I said, Hello Mr Jenkins
@2020 copyright KalKey training
USING ENVIRONMENT VARIABLES
• Jenkins Pipeline exposes environment variables via the global variable env, which is available from anywhere within
a Jenkinsfile.
• Declarative Pipeline:
pipeline {
agent any
environment {
NAME = 'ricardo'
LASTNAME = 'gonzalez'
}
stages {
stage('Build') {
steps {
sh 'echo $NAME $LASTNAME'
}
}
}
}@2020 copyright KalKey training
PLUGIN INTEGRATION
• Git Setup
Configure Git pulgin on Jenkins
Git is one of the most popular tools for version control system. you can pull code from git repositories
using jenkins if you use github plugin.
Prerequisites:
Jenkins server
Install Git on Jenkins server
yum install git –y
Setup Git on jenkins console
Install git plugin without restart
Manage Jenkins > Jenkins Plugins > available > github
Configure git path
Manage Jenkins > Global Tool Configuration > git
@2020 copyright KalKey training
MAVEN INTRODUCTION
• Maven is a powerful project management tool that is based on POM (project object model). It is used
for projects build, dependency and documentation.
• Building a software project typically consists of such tasks as downloading dependencies, putting
additional jars on a class-path, compiling source code into binary code, running tests, packaging
compiled code into deployable artifacts such as JAR, WAR, and ZIP files, and deploying these
artifacts to an application server or repository.
• Apache Maven automates these tasks, minimizing the risk of humans making errors while building the
software manually and separating the work of compiling and packaging our code from that of code
construction
@2020 copyright KalKey training
WHY USE MAVEN?
• Simple project setup that follows best practices: Maven tries to avoid as much configuration as
possible, by supplying project templates.
• Dependency Management: It includes automatic updating, downloading and validating the
compatibility, as well as reporting the dependency closures
• Isolation between project Dependencies and Plugins: With Maven, project dependencies are retrieved
from the dependency repositories while any plugin's dependencies are retrieved from the plugin
repositories, resulting in fewer conflicts when plugins start to download additional dependencies.
• Central Repository System: Project dependencies can be loaded from the local file system or public
repositories, such as Maven Central
@2020 copyright KalKey training
PROJECT OBJECT MODEL(POM)
• The configuration of a Maven project is done via a Project Object Model (POM), represented by a
pom.xml file. The POM describes the project, manages dependencies, and configures plugins for
building the software.
• The POM also defines the relationships among modules of multi-module projects.
@2020 copyright KalKey training
LET'S LOOK AT THE
BASIC STRUCTURE OF
A TYPICAL POM FILE:
@2020 copyright KalKey training
PROJECT IDENTIFIERS
• Maven uses a set of identifiers, also called coordinates, to uniquely identify a project and specify how
the project artifact should be packaged:
• groupId – a unique base name of the company or group that created the project
• artifactId – a unique name of the project
• version – a version of the project
• packaging – a packaging method (e.g. WAR/JAR/ZIP)
The first three of these (groupId:artifactId:version) combine to form the unique identifier and are the
mechanism by which you specify which versions of external libraries (e.g. JARs) your project will use.
@2020 copyright KalKey training
DEPENDENCIES
• These external libraries that a project uses are called dependencies. The dependency management
feature in Maven ensures automatic download of those libraries from a central repository, so you don't
have to store them locally.
• This is a key feature of Maven and provides the following benefits:
• uses less storage by significantly reducing the number of downloads off remote repositories
• makes checking out a project quicker
• provides an effective platform for exchanging binary artifacts within your organization and beyond
without the need for building artifact from source every time
@2020 copyright KalKey training
CONT….
• In order to declare a dependency on an
external library, you need to provide the
groupId, artifactId, and the version of the
library. Let's take a look at an example:
@2020 copyright KalKey training
REPOSITORIES
• A repository in Maven is used to hold build artifacts and dependencies of varying types. The default local
repository is located in the .m2/repository folder under the home directory of the user.
• If an artifact or a plug-in is available in the local repository, Maven uses it. Otherwise, it is downloaded
from a central repository and stored in the local repository. The default central repository is Maven
Central.
@2020 copyright KalKey training
CONT….
• Some libraries, such as JBoss server, are not
available at the central repository but are
available at an alternate repository. For those
libraries, you need to provide the URL to the
alternate repository inside pom.xml file:
@2020 copyright KalKey training
PROPERTIES
• Custom properties can help to make your pom.xml file easier to read and maintain. In the classic use
case, you would use custom properties to define versions for your project's dependencies.
• Maven properties are value-placeholders and are accessible anywhere within a pom.xml by using the
notation ${name}, where name is the property.
• Let's see an example: in next slide
@2020 copyright KalKey training
CONT…
• Now if you want to
upgrade Spring to a
newer version, you
only have to change
the value inside
the<spring.version>
property tag and all the
dependencies using
that property in their
<version> tags will be
updated.
@2020 copyright KalKey training
BUILD
• The build section is also a
very important section of the
Maven POM. It provides
information about the default
Maven goal, the directory for
the compiled project, and the
final name of the application.
The default build section
looks like this:
• The default output folder for
compiled artifacts is named
target, and the final name of
the packaged artifact consists
of the artifactId and version,
but you can change it at any
time.
@2020 copyright KalKey training
USING
PROFILES
• Another important feature
of Maven is its support
for profiles. A profile is
basically a set of
configuration values. By
using profiles, you can
customize the build for
different environments
such as
Production/Test/Develop
ment:
@2020 copyright KalKey training
MAVEN BUILD LIFECYCLES
• Every Maven build follows a specified lifecycle. You can execute several build lifecycle goals, including
the ones to compile the project’s code, create a package, and install the archive file in the local Maven
dependency repository.
@2020 copyright KalKey training
LIFECYCLE PHASES
• Validate – checks the correctness of the project
• Compile – compiles the provided source code into binary artifacts
• Test – executes unit tests
• Package – packages compiled code into an archive file
• Integration-test – executes additional tests, which require the packaging
• Verify – checks if the package is valid
• Install – installs the package file into the local Maven repository
• Deploy – deploys the package file to a remote server or repository
@2020 copyright KalKey training
CONT…
Maven Setup
Install & configure Maven build tool on Jenkins
Maven is a code build tool which used to convert your code to an artifact. this is a widely used plugin to build in continuous integration
Prerequisites
Jenkins server
Install Maven on Jenkins
1. Download maven packages https://maven.apache.org/download.cgi onto Jenkins server. In this case, I am using /opt/maven as my installation directory
Link : https://maven.apache.org/download.cgi
# Creating maven directory under /opt
mkdir /opt/maven cd /opt/maven
# downloading maven version 3.6.0
Wget http://mirrors.estointernet.in/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
tar -xvzf apache-maven-3.6.1-bin.tar.gz
2. Setup M2_HOME and M2 paths in .bash_profile of the user and add these to the path variable
vi ~/.bash_profile
M2_HOME=/opt/maven/apache-maven-3.6.1
M2=$M2_HOME/bin
PATH=<Existing_PATH>:$M2_HOME:$M2
@2020 copyright KalKey training
CHECKPOINT
• logoff and login to check maven version
mvn –version
• So far we have completed the installation of maven software to support maven plugin on the jenkins
console. Let's jump onto Jenkins to complete the remaining steps.
• Setup maven on Jenkins console:
1. Install maven plugin without restart
• Manage Jenkins > Jenkins Plugins > available > Maven Invoker
• Manage Jenkins > Jenkins Plugins > available > Maven Integration
2. Configure maven path
• Manage Jenkins > Global Tool Configuration > Maven
@2020 copyright KalKey training
DEMO
@2020 copyright KalKey training

Weitere ähnliche Inhalte

Was ist angesagt?

Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Simplilearn
 
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
Simplilearn
 

Was ist angesagt? (18)

Docker swarm
Docker swarmDocker swarm
Docker swarm
 
Docker vs VM | | Containerization or Virtualization - The Differences | DevOp...
Docker vs VM | | Containerization or Virtualization - The Differences | DevOp...Docker vs VM | | Containerization or Virtualization - The Differences | DevOp...
Docker vs VM | | Containerization or Virtualization - The Differences | DevOp...
 
Getting Started With Docker | Docker Tutorial | Docker Training | Edureka
Getting Started With Docker | Docker Tutorial | Docker Training | EdurekaGetting Started With Docker | Docker Tutorial | Docker Training | Edureka
Getting Started With Docker | Docker Tutorial | Docker Training | Edureka
 
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and Containers
 
What is Docker?
What is Docker?What is Docker?
What is Docker?
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Docker container a-brief_introduction_2016-01-30
Docker container a-brief_introduction_2016-01-30Docker container a-brief_introduction_2016-01-30
Docker container a-brief_introduction_2016-01-30
 
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
Docker Explained | What Is A Docker Container? | Docker Simplified | Docker T...
 
Jenkins 1
Jenkins 1Jenkins 1
Jenkins 1
 
Developing with Docker for the Arm Architecture
Developing with Docker for the Arm ArchitectureDeveloping with Docker for the Arm Architecture
Developing with Docker for the Arm Architecture
 
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
 
Introduction to container based virtualization with docker
Introduction to container based virtualization with dockerIntroduction to container based virtualization with docker
Introduction to container based virtualization with docker
 
Docker & kubernetes
Docker & kubernetesDocker & kubernetes
Docker & kubernetes
 
Docker Container-Introduction and Features
Docker Container-Introduction and FeaturesDocker Container-Introduction and Features
Docker Container-Introduction and Features
 
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
What Is A Docker Container? | Docker Container Tutorial For Beginners| Docker...
 
Docker Basic to Advance
Docker Basic to AdvanceDocker Basic to Advance
Docker Basic to Advance
 
Introduction to Docker - VIT Campus
Introduction to Docker - VIT CampusIntroduction to Docker - VIT Campus
Introduction to Docker - VIT Campus
 

Ähnlich wie Jenkins advance topic

Continous Integration.pptx
Continous Integration.pptxContinous Integration.pptx
Continous Integration.pptx
Anuj Sharma
 
Maven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension toolMaven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension tool
elliando dias
 
Jenkins introduction
Jenkins introductionJenkins introduction
Jenkins introduction
Gourav Varma
 
Jenkins introduction
Jenkins introductionJenkins introduction
Jenkins introduction
Kalkey
 

Ähnlich wie Jenkins advance topic (20)

Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with Maven
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Session 2
Session 2Session 2
Session 2
 
Session 2
Session 2Session 2
Session 2
 
Maven
MavenMaven
Maven
 
(Re)-Introduction to Maven
(Re)-Introduction to Maven(Re)-Introduction to Maven
(Re)-Introduction to Maven
 
Continous Integration.pptx
Continous Integration.pptxContinous Integration.pptx
Continous Integration.pptx
 
Pragmatic software development in kdb+
Pragmatic software development in kdb+Pragmatic software development in kdb+
Pragmatic software development in kdb+
 
Introduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS worldIntroduction to maven, its configuration, lifecycle and relationship to JS world
Introduction to maven, its configuration, lifecycle and relationship to JS world
 
Mavennotes.pdf
Mavennotes.pdfMavennotes.pdf
Mavennotes.pdf
 
Jenkins Pipelining and Gatling Integration
Jenkins Pipelining and  Gatling IntegrationJenkins Pipelining and  Gatling Integration
Jenkins Pipelining and Gatling Integration
 
Jenkins.pdf
Jenkins.pdfJenkins.pdf
Jenkins.pdf
 
Maven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension toolMaven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension tool
 
Jenkins introduction
Jenkins introductionJenkins introduction
Jenkins introduction
 
Jenkins introduction
Jenkins introductionJenkins introduction
Jenkins introduction
 
Implementing CI CD UiPath Using Jenkins Plugin
Implementing CI CD UiPath Using Jenkins PluginImplementing CI CD UiPath Using Jenkins Plugin
Implementing CI CD UiPath Using Jenkins Plugin
 
Pipeline as code - new feature in Jenkins 2
Pipeline as code - new feature in Jenkins 2Pipeline as code - new feature in Jenkins 2
Pipeline as code - new feature in Jenkins 2
 
Maven
MavenMaven
Maven
 

Mehr von Kalkey

Docker swarm
Docker swarmDocker swarm
Docker swarm
Kalkey
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)
Kalkey
 
Sonarqube
SonarqubeSonarqube
Sonarqube
Kalkey
 
Introduction of tomcat
Introduction of tomcatIntroduction of tomcat
Introduction of tomcat
Kalkey
 
Cloud computing 1
Cloud computing  1Cloud computing  1
Cloud computing 1
Kalkey
 
Adnible day 2.ppt
Adnible day   2.pptAdnible day   2.ppt
Adnible day 2.ppt
Kalkey
 
Shell programming 1.ppt
Shell programming  1.pptShell programming  1.ppt
Shell programming 1.ppt
Kalkey
 

Mehr von Kalkey (20)

Docker swarm
Docker swarmDocker swarm
Docker swarm
 
Docker advance topic (2)
Docker advance topic (2)Docker advance topic (2)
Docker advance topic (2)
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)
 
Nexus
NexusNexus
Nexus
 
Sonarqube
SonarqubeSonarqube
Sonarqube
 
Introduction of tomcat
Introduction of tomcatIntroduction of tomcat
Introduction of tomcat
 
Intro
IntroIntro
Intro
 
Terraform day 3
Terraform day 3Terraform day 3
Terraform day 3
 
Terraform day 2
Terraform day 2Terraform day 2
Terraform day 2
 
Terraform day 1
Terraform day 1Terraform day 1
Terraform day 1
 
Ansible day 3
Ansible day 3Ansible day 3
Ansible day 3
 
Cloud computing 1
Cloud computing  1Cloud computing  1
Cloud computing 1
 
Shell programming 2
Shell programming 2Shell programming 2
Shell programming 2
 
Adnible day 2.ppt
Adnible day   2.pptAdnible day   2.ppt
Adnible day 2.ppt
 
Shell programming 1.ppt
Shell programming  1.pptShell programming  1.ppt
Shell programming 1.ppt
 
Debasihish da final.ppt
Debasihish da final.pptDebasihish da final.ppt
Debasihish da final.ppt
 
Linux day 3ppt
Linux day 3pptLinux day 3ppt
Linux day 3ppt
 
Ansible day 1.ppt
Ansible day 1.pptAnsible day 1.ppt
Ansible day 1.ppt
 
Linux day 2.ppt
Linux day  2.pptLinux day  2.ppt
Linux day 2.ppt
 
Docker advance topic
Docker advance topicDocker advance topic
Docker advance topic
 

Kürzlich hochgeladen

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Kürzlich hochgeladen (20)

fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 

Jenkins advance topic

  • 1. JENKINS’ MASTER AND SLAVE ARCHITECTURE @2020 copyright KalKey training
  • 2. MASTER AND SLAVE ARCHITECTURE @2020 copyright KalKey training
  • 3. INTRODUCTION OF JENKINSFILE • A continuous delivery pipeline is an automated expression of your process for getting software from version control right through to your users and customers. @2020 copyright KalKey training
  • 4. CREATING A JENKINSFILE • The current Jenkinsfile has two ways of writing, and pipeline if it is the root, it is called Declarative Pipeline. In this case, you cannot write the Groovy script directly, and if you want to write Groovy you script need to use the directive. • Pipeline If that does not start from, say Scripted Pipeline, to this case also write directly Groovy script, node() arrow stage(), such as, can also be written Pipeline Steps method. Although it seems convenient, degrees of freedom are too high and tend to be craftsmen code. @2020 copyright KalKey training
  • 5. JENKINS PIPELINE & COMPONENTS • What is Jenkins Pipeline? Jenkins Pipeline (or simply "Pipeline" with a capital "P") is a suite of plugins which supports implementing and integrating continuous delivery pipelines into Jenkins. • 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. Also, a pipeline block is a key part of Declarative Pipeline syntax. • Node A node is a machine which is part of the Jenkins environment and is capable of executing a Pipeline. Also, a node block is a key part of Scripted Pipeline syntax. @2020 copyright KalKey training
  • 6. CONT…. • 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). For example, to execute the shell command make use the sh step: sh 'make'. When a plugin extends the Pipeline DSL, [1] that typically means the plugin has implemented a new step @2020 copyright KalKey training
  • 7. JENKINSFILE (DECLARATIVE PIPELINE) pipeline { agent any stages { stage('Build') { steps { echo "We are in Build Stage" } } stage('Test') { steps { echo "We are in Test Stage" } } stage('Deploy') { steps { echo "We are in Deploy Stage" } } } } @2020 copyright KalKey training
  • 8. JENKINSFILE (SCRIPTED PIPELINE) node { stage('Build') { echo “Build stage” } stage('Test') { echo “Test stage” } stage('Deploy') { echo “Deploy stage” } } @2020 copyright KalKey training
  • 9. STRING INTERPOLATION • Jenkins Pipeline uses rules identical to Groovy for string interpolation. • While Groovy supports declaring a string with either single quotes, or double quotes def username = 'Jenkins' echo 'Hello Mr. ${username}' echo "I said, Hello Mr. ${username}“ Result: Hello Mr. Jenkins I said, Hello Mr Jenkins @2020 copyright KalKey training
  • 10. USING ENVIRONMENT VARIABLES • Jenkins Pipeline exposes environment variables via the global variable env, which is available from anywhere within a Jenkinsfile. • Declarative Pipeline: pipeline { agent any environment { NAME = 'ricardo' LASTNAME = 'gonzalez' } stages { stage('Build') { steps { sh 'echo $NAME $LASTNAME' } } } }@2020 copyright KalKey training
  • 11. PLUGIN INTEGRATION • Git Setup Configure Git pulgin on Jenkins Git is one of the most popular tools for version control system. you can pull code from git repositories using jenkins if you use github plugin. Prerequisites: Jenkins server Install Git on Jenkins server yum install git –y Setup Git on jenkins console Install git plugin without restart Manage Jenkins > Jenkins Plugins > available > github Configure git path Manage Jenkins > Global Tool Configuration > git @2020 copyright KalKey training
  • 12. MAVEN INTRODUCTION • Maven is a powerful project management tool that is based on POM (project object model). It is used for projects build, dependency and documentation. • Building a software project typically consists of such tasks as downloading dependencies, putting additional jars on a class-path, compiling source code into binary code, running tests, packaging compiled code into deployable artifacts such as JAR, WAR, and ZIP files, and deploying these artifacts to an application server or repository. • Apache Maven automates these tasks, minimizing the risk of humans making errors while building the software manually and separating the work of compiling and packaging our code from that of code construction @2020 copyright KalKey training
  • 13. WHY USE MAVEN? • Simple project setup that follows best practices: Maven tries to avoid as much configuration as possible, by supplying project templates. • Dependency Management: It includes automatic updating, downloading and validating the compatibility, as well as reporting the dependency closures • Isolation between project Dependencies and Plugins: With Maven, project dependencies are retrieved from the dependency repositories while any plugin's dependencies are retrieved from the plugin repositories, resulting in fewer conflicts when plugins start to download additional dependencies. • Central Repository System: Project dependencies can be loaded from the local file system or public repositories, such as Maven Central @2020 copyright KalKey training
  • 14. PROJECT OBJECT MODEL(POM) • The configuration of a Maven project is done via a Project Object Model (POM), represented by a pom.xml file. The POM describes the project, manages dependencies, and configures plugins for building the software. • The POM also defines the relationships among modules of multi-module projects. @2020 copyright KalKey training
  • 15. LET'S LOOK AT THE BASIC STRUCTURE OF A TYPICAL POM FILE: @2020 copyright KalKey training
  • 16. PROJECT IDENTIFIERS • Maven uses a set of identifiers, also called coordinates, to uniquely identify a project and specify how the project artifact should be packaged: • groupId – a unique base name of the company or group that created the project • artifactId – a unique name of the project • version – a version of the project • packaging – a packaging method (e.g. WAR/JAR/ZIP) The first three of these (groupId:artifactId:version) combine to form the unique identifier and are the mechanism by which you specify which versions of external libraries (e.g. JARs) your project will use. @2020 copyright KalKey training
  • 17. DEPENDENCIES • These external libraries that a project uses are called dependencies. The dependency management feature in Maven ensures automatic download of those libraries from a central repository, so you don't have to store them locally. • This is a key feature of Maven and provides the following benefits: • uses less storage by significantly reducing the number of downloads off remote repositories • makes checking out a project quicker • provides an effective platform for exchanging binary artifacts within your organization and beyond without the need for building artifact from source every time @2020 copyright KalKey training
  • 18. CONT…. • In order to declare a dependency on an external library, you need to provide the groupId, artifactId, and the version of the library. Let's take a look at an example: @2020 copyright KalKey training
  • 19. REPOSITORIES • A repository in Maven is used to hold build artifacts and dependencies of varying types. The default local repository is located in the .m2/repository folder under the home directory of the user. • If an artifact or a plug-in is available in the local repository, Maven uses it. Otherwise, it is downloaded from a central repository and stored in the local repository. The default central repository is Maven Central. @2020 copyright KalKey training
  • 20. CONT…. • Some libraries, such as JBoss server, are not available at the central repository but are available at an alternate repository. For those libraries, you need to provide the URL to the alternate repository inside pom.xml file: @2020 copyright KalKey training
  • 21. PROPERTIES • Custom properties can help to make your pom.xml file easier to read and maintain. In the classic use case, you would use custom properties to define versions for your project's dependencies. • Maven properties are value-placeholders and are accessible anywhere within a pom.xml by using the notation ${name}, where name is the property. • Let's see an example: in next slide @2020 copyright KalKey training
  • 22. CONT… • Now if you want to upgrade Spring to a newer version, you only have to change the value inside the<spring.version> property tag and all the dependencies using that property in their <version> tags will be updated. @2020 copyright KalKey training
  • 23. BUILD • The build section is also a very important section of the Maven POM. It provides information about the default Maven goal, the directory for the compiled project, and the final name of the application. The default build section looks like this: • The default output folder for compiled artifacts is named target, and the final name of the packaged artifact consists of the artifactId and version, but you can change it at any time. @2020 copyright KalKey training
  • 24. USING PROFILES • Another important feature of Maven is its support for profiles. A profile is basically a set of configuration values. By using profiles, you can customize the build for different environments such as Production/Test/Develop ment: @2020 copyright KalKey training
  • 25. MAVEN BUILD LIFECYCLES • Every Maven build follows a specified lifecycle. You can execute several build lifecycle goals, including the ones to compile the project’s code, create a package, and install the archive file in the local Maven dependency repository. @2020 copyright KalKey training
  • 26. LIFECYCLE PHASES • Validate – checks the correctness of the project • Compile – compiles the provided source code into binary artifacts • Test – executes unit tests • Package – packages compiled code into an archive file • Integration-test – executes additional tests, which require the packaging • Verify – checks if the package is valid • Install – installs the package file into the local Maven repository • Deploy – deploys the package file to a remote server or repository @2020 copyright KalKey training
  • 27. CONT… Maven Setup Install & configure Maven build tool on Jenkins Maven is a code build tool which used to convert your code to an artifact. this is a widely used plugin to build in continuous integration Prerequisites Jenkins server Install Maven on Jenkins 1. Download maven packages https://maven.apache.org/download.cgi onto Jenkins server. In this case, I am using /opt/maven as my installation directory Link : https://maven.apache.org/download.cgi # Creating maven directory under /opt mkdir /opt/maven cd /opt/maven # downloading maven version 3.6.0 Wget http://mirrors.estointernet.in/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz tar -xvzf apache-maven-3.6.1-bin.tar.gz 2. Setup M2_HOME and M2 paths in .bash_profile of the user and add these to the path variable vi ~/.bash_profile M2_HOME=/opt/maven/apache-maven-3.6.1 M2=$M2_HOME/bin PATH=<Existing_PATH>:$M2_HOME:$M2 @2020 copyright KalKey training
  • 28. CHECKPOINT • logoff and login to check maven version mvn –version • So far we have completed the installation of maven software to support maven plugin on the jenkins console. Let's jump onto Jenkins to complete the remaining steps. • Setup maven on Jenkins console: 1. Install maven plugin without restart • Manage Jenkins > Jenkins Plugins > available > Maven Invoker • Manage Jenkins > Jenkins Plugins > available > Maven Integration 2. Configure maven path • Manage Jenkins > Global Tool Configuration > Maven @2020 copyright KalKey training