SlideShare a Scribd company logo
1 of 76
Beginners Guide
What is Continuous Integration?
Continuous Integration
• As defined by Martin Fowler
• In software engineering CI implements continuous process of applying quality control – small
pieces of effort applied frequently.
• It aims to improve the quality of software and to reduce time taken to deliver.
• This is done by replacing the traditional practice of applying quality control after completing
development with continuous integration.
What is CI?
• What it is
A development Methodology.
A daily developer integration.
Automated builds.
Continuous Integration Basics
CI Tools
Jenkins
• Written in java
• Runs inside servlet container.
• Primarily written and developed by kosuke kawaguchi.
• Split from Hudson.
• Easy to install.
• Over 600+ Plugins.
• Can be scripted.
Who uses Jenkins
Install Jenkins
• Can be installed as
1. WAR
2. Native package.
https://jenkins.io/download/
First Jenkins Job
• Start a Freestyle Job
• Just build to execute one shell script.
• Job will be named Hello World.
• In the build section choose “Execute windows batch command”. From
Add build steps.
• Click Apply.
• In command area type “echo hello world”.
• Click save.
• To run the build click Build Now.
• The console output shows a temporary batch file created by Jenkins
and execute by your behalf.
Plugins
Jenkins plugins
Default Plugin Description
ANT Use to run talk from build.xml
Credentials To store Credentials in Jenkins
JavaDoc Publishes Javadoc
Junit Publishes junit test results
Mailer Supports Mail Sending
Subversion Supports SVN
Maven Integration Integration Jenkins with maven.
LDAP LDAP Authentication support
Jenkins Plugin Interface
Plugin Tabs
Updates – Shows updates to already installed plugins.
Available – Shows plugins that are available for installation.
Installed – Shows plugins installed that have no problem.
Advanced – Allows manual upload of plugins
Pinning of Plugins
• Plugins that are bundled or preinstalled with Jenkins can be pinned.
• When Jenkins are updated all the plugins preinstalled are also
updated.
• But if any bundled plugin is manually updated it gets pinned to
current version of Jenkins.
• Update of Jenkins will not update this plugin.
• /Plugins/plugin_name.jpi.pinned is created.
• You can Unpin which means you are allowing the updates to happen.
Global Tools
• Manage Jenkins -> Global Tool Configuration
• Configure tools, their locations and automatic installers.
Automatic Install
• Install automatically allows you to have custom installers or scripts.
• Default is “Install from Apache” .
• Else you can extract an already downloaded file.
Maven Plugin
• In addition to other env variable maven plugin makes below variables available to your jobs or
scripts.
• This plugin exposes variables found from the project's POM (as of version 2.1):
• POM_DISPLAYNAME
• POM_VERSION
• POM_GROUPID
• POM_ARTIFACTID
• POM_PACKAGING
Javadoc Plugin
• Publishes your Javadoc if created by your build.
• Maven Projects
• Goal to run Javadoc:Javadoc
• Freestyle Projects
• Under “Add post-build action” -> Publish Javadoc
HTML Publisher
• Use to generate HTML files during the build.
• You can publish PMD Reports, Java Docs etc.
Git HUB
• It allows you to connect Git Hub with Jenkins.
• Trigger a build whenever push to repository happens.
Git Hub Tokens
• Goto Git Hub , log in, go to settings, personal access tokens , click on
Generate new token.
• Check repo:status
• Click on Generate Token and copy it.
• In Jenkins Management - > Configure System, Add a new GITHUB
server config.
• API URL: https://api.github.com
• Check Manage Hooks Check box.
• Click Add Button next to Credentials.
• Enter Credentials in the dialog box( Screen 2)
Configure GitHub – Screen 1
.
Jenkins Credentials Provider – Screen 2
Automatic Build when code is pushed
• You will then have to tick the box indicated below – “Build when a change is pushed to GitHub”
Contd.
• Manage Jenkins -> Manage Plugins -> Available -> GitHub plugin
• Copy the url in « Override Hook URL. And uncheck specify another hook url for GitHub Configurations.
Contd.
• The GitHub steps are pretty straight forward. Open the “Webhooks
& Services” tab -> choose “Configure Services” -> find the Jenkins
(GitHub plugin option) and fill it in with a similar URL to the
following:
• http://<Name of Jenkins server>:8080/github-webhook/
Add WebHooks in Git Hub
• The GitHub steps are pretty straight forward. Open the “Webhooks & Services” tab -> choose “Configure
Services” -> find the Jenkins (GitHub plugin option) and fill it in with a similar URL to the following:
• http://<Name of Jenkins server>:8080/github-webhook/
Parameterised Builds
• Allows user to provide parameters for Build in a URL.
• Users are prompted to enter parameters before triggering build.
• Exposes $Jenkins/job/$job/parambuild URL to trigger build with
parameter.
Credential Plugin
• Provides convenient way to organize credentials across domains and
maintains password secret once.
• Used by other plugins indirectly when you are required to provide
credentials.
• There are multiple credentials plugin including.
• Plain credentials
• SSH Credentials
• Google Oath
• Dockers Common
Credential Plugin
• Kinds of Credentials
• Username with password
• SSH Username with private key
• Certificate.
• Scope of Credentials
• Global- Available to the object on which credentials is associated and all
objects that are children on that object.
• System – Only available to object on which credentials is associated.
Eg email
Jenkins Copy Artifact
• Allows you to copy artifacts built from other jobs into current workspace.
• Select the option from Build Steps.
Jenkins Copy Artifact (Contd)
• Files matched by the "Artifacts to copy" field are copied to the same directory structure as the
source build had You can use the "Flatten directories" option if you want the file(s) to be copied
to the root of the build workspace.
• Projects must enable “permission to copy Artifact” and select the project which is authorized to
copy artifacts.
• The location from which the artifacts are copied from is relative to:
• - the artifacts folder,
• - for the selected build,
• - for the job you selected to copy from
• So, first things first, you have to make sure that the job that you are copying from is actually
archiving the artifacts. It will not copy files from workspace (there are other plugins for that).
• To archive your artifacts, in the job the creates them, select post-build action "Archive the
artifacts", then provide a list of artifacts you want to archive, relative to workspace. For example,
to archive all zip files, regardless of where they are, use:
**/*.zip
• Or if you know that all your artifacts are inside the "build" folder, but there may be intermediate
directories in between, use:
build/**/*.zip
• Or simply provide a full path:
build/myartifactsfolder/myfile.zip
Jenkins Copy Artifact (Contd)
Jenkins Copy Artifact (Contd)
• Now, to view the artifacts available, navigate in your browser to the URL of the job from which
you want to copy, select the build you wish to copy from, and then append /artifact/ at the end,
or just click "Build Artifacts" link on the page:
example: http://localhost/job/YourJob/lastBuild/artifact/
• This will show a directory structure and all available artifacts. You can reference this in the "Copy
Artifacts" post-build step directly. Or you can use wildcards. For example, if you want to ignore
any directory structure, and just copy all *.zip files, your "Artifacts to copy" field should be:
**/*.zip
• The double stars ignore directories in between. You can use comma to separate multiple entries.
Alternatively, if you leave this field blank, it will copy all available artifacts.
• On the receiving end, the "Target directory" is relative to the Workspace of the job that is calling
the "Copy Artifacts" step.
• Lastly, if you don't care about the directory structure, check mark the "Flatten directories" option,
so that all artifacts end up in the same place, ignoring any folders in between.
Triggers
• Manual Build
• Click manually build now.
• On Schedule
• Use UNIX Cron rotation
• Minutes
• Hours
• Day of month
• Month
• Day of week
• When code changes in SCM
• Polling SCM
• Triggered on other builds.
Triggers (Contd)
Cron Format
• Jenkins uses UNIX Cron notation
• Minutes (0-59)
• * represents every value ***** means once every minute.
• / allows you to skip e.g. */5 means every 5 minute.
• Hours (0-23)
• Commas represents list of values e.g. 2,3 means at 2 and 3 am in morning.
• Day of month (1-31)
• Month (1-12)
• Day of week (0-7)
• Ranges are allowed 1-5 means between Monday to Friday.
1. By setting the schedule period to 15 13 * * * you tell jenkins to schedule the build every day of every month of every year at the 15th
minute of the 13th hour of the day.
2. If you want to schedule your build every 5 minutes, this will do the job : */5 * * * *
3. If you want to schedule your build every day at 8h00, this will do the job : 0 8 * * *
Cron (Contd)
• Jenkins lets you set up multiple times, separated by line breaks.
• If you need it to build daily at 7am, along with every Sunday at 4pm, the below works well
• H 7 * * *
• H 16 * * 0
Types of JOB
• Maven
• Free Style
• Monitor an External Job
• Multi Configurations jobs
Screen 1
Maven vs FreeStyle
• A maven project is a project that will analyze the pom.xml file in greater detail and
produce a project that's geared towards the targets that are invoked. The maven project
is smart enough to incorporate build targets like the javadoc or test targets and
automatically setup the reports for those targets. There is little configuration required for
it. See: http://wiki.hudson-ci.org/display/HUDSON/Building+a+maven2+project for more
information on Maven project.
• A Free-Style project is a project that can incorporate almost any type of build. While a
maven project you can only build maven projects, the Free-Style project is the more
"generic" form of a project. You can execute shell/dos scripts, invoke ant, and a lot more.
Majority of the plugins are written to use the free-style project. The maven module is
limited in that it can't invoke a shell script, or anything else just the maven targets. See:
http://wiki.hudson-ci.org/display/HUDSON/Building+a+software+project for more
information on a Free-Style project.
Multi Configuration
Multi Configuration (Contd.)
Email
Email
Email
Navigate to https://myaccount.google.com/lesssecureapps?pli=1
• Please enter your Gmail id when prompted while accessing the above url
• Now turn on Allow less secure apps (This will enable your Gmail SMTP to interact with jenkins)
Email / IRC integration
Follow the steps as illustrated in previous slides
Go to localhost:8080 (default port for Jenkins)
Navigate to Manage Jenkins  Configure System
Tick , Use SMTP Authentication
Follow the details as per screenshot
Give the username and password
Tick, Use SSL
Enter SMTP port
Reply to address
Charset
Please enter a recipient email address
Test by clicking on Test configuration
Email Functionality
• Default Email notification in Jenkins Post Build Action.
• Email address can be separated by commas.
Email (Contd)
• Use Email Template management plugin if you don’t want use default
one.
Authorization – Create User
User Access – Assign Roles to User
Parameterization
• Jenkins allows parameters to be set for builds.
• While configuring job check the below option.
Parameterization (Contd)
• Simple Types
• Boolean
• Choice(Dropdown)
• String
• Text(Same as string but allow new lines)
• Password(masked string)
• Complex Types
• File Parameters(Allows file to be uploaded)
• Run parameters – Access past builds
• Build Selector for copy artifact.
Parameterization (Contd)
• A parameterized job can be accessed by posting to
• https://<yourserver>/job/$job/buildwithParameteres?PARAMETER=v
alue
Junit Test Report
• Just make sure you build the maven with test profile.
Health report amplification factor
• The amplification factor to apply to test failures when computing the test result contribution to
the build health score.
• The default factor is 1.0
• A factor of 0.0 will disable the test result contribution to build health score.
• A factor of 0.1 means that 10% of tests failing will score 99% health
• A factor of 0.5 means that 10% of tests failing will score 95% health
• A factor of 1.0 means that 10% of tests failing will score 90% health
• A factor of 2.0 means that 10% of tests failing will score 80% health
• A factor of 2.5 means that 10% of tests failing will score 75% health
• A factor of 5.0 means that 10% of tests failing will score 50% health
• A factor of 10.0 means that 10% of tests failing will score 0% health
Contd
Junit Test Report – Displaying test results
Junit report (Contd)
Publish HTML Reports
Sample Report for PMD Plugin (Code
Coverage tool)
Code Coverage Tool
Maven and Code Coverage Tool Goals
• For PMD:- pmd:pmd
• For Corbertura:- cobertura:cobertura
• For Find bugs :- findbugs:findbugs
Cobertura Plugin – Post Build Actions
Sample Cobertura Report
Configure Pom.xml
• To know how to configure pom.xml to set up code coverage tools.
• Refer pom.xml of this project:
https://github.com/Viyaan/JenkinsJobFlow
HTML Validation
• Install Unicorn Validator
• In Build step select unicorn validator.
• Enter the URL of site to validate.
HTML Validation Report
Backup and Restore
• Install back up plugin.
Set up for Backup Manager Plugin
Backup Manager plugin parameters
• Backup directory: A shared folder where back up is dumped.
• Format: At what format it is dumped.
• Verbose: Backup will be logged.
• If you want to schedule your back periodically use thinBackup plugin.

More Related Content

What's hot

Yale Jenkins Show and Tell
Yale Jenkins Show and TellYale Jenkins Show and Tell
Yale Jenkins Show and Tell
E. Camden Fisher
 

What's hot (20)

Jenkins Introduction
Jenkins IntroductionJenkins Introduction
Jenkins Introduction
 
Introduction to jenkins
Introduction to jenkinsIntroduction to jenkins
Introduction to jenkins
 
Jenkins
JenkinsJenkins
Jenkins
 
Jenkins presentation
Jenkins presentationJenkins presentation
Jenkins presentation
 
An Introduction To Jenkins
An Introduction To JenkinsAn Introduction To Jenkins
An Introduction To Jenkins
 
Jenkins for java world
Jenkins for java worldJenkins for java world
Jenkins for java world
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
 
Yale Jenkins Show and Tell
Yale Jenkins Show and TellYale Jenkins Show and Tell
Yale Jenkins Show and Tell
 
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
CI CD Pipeline Using Jenkins | Continuous Integration and Deployment | DevOps...
 
Jenkins CI presentation
Jenkins CI presentationJenkins CI presentation
Jenkins CI presentation
 
CI/CD (DevOps) 101
CI/CD (DevOps) 101CI/CD (DevOps) 101
CI/CD (DevOps) 101
 
CICD with Jenkins
CICD with JenkinsCICD with Jenkins
CICD with Jenkins
 
What is Jenkins | Jenkins Tutorial for Beginners | Edureka
What is Jenkins | Jenkins Tutorial for Beginners | EdurekaWhat is Jenkins | Jenkins Tutorial for Beginners | Edureka
What is Jenkins | Jenkins Tutorial for Beginners | Edureka
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
Docker introduction &amp; benefits
Docker introduction &amp; benefitsDocker introduction &amp; benefits
Docker introduction &amp; benefits
 
Introduction to CI/CD
Introduction to CI/CDIntroduction to CI/CD
Introduction to CI/CD
 
CICD Pipeline Using Github Actions
CICD Pipeline Using Github ActionsCICD Pipeline Using Github Actions
CICD Pipeline Using Github Actions
 
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
What is Docker | Docker Tutorial for Beginners | Docker Container | DevOps To...
 
CI/CD with Github Actions
CI/CD with Github ActionsCI/CD with Github Actions
CI/CD with Github Actions
 
Maven
MavenMaven
Maven
 

Similar to Jenkins CI

Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/HudsonEclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
VladLica
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
Ulrich Krause
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
Kalkey
 
The Basic Concept Of IOC
The Basic Concept Of IOCThe Basic Concept Of IOC
The Basic Concept Of IOC
Carl Lu
 

Similar to Jenkins CI (20)

Eclipse IDE, 2019.09, Java Development
Eclipse IDE, 2019.09, Java Development Eclipse IDE, 2019.09, Java Development
Eclipse IDE, 2019.09, Java Development
 
Introduction to jenkins for the net developer
Introduction to jenkins for the net developerIntroduction to jenkins for the net developer
Introduction to jenkins for the net developer
 
IBM Bluemix - Building a Project with Maven
IBM Bluemix - Building a Project with MavenIBM Bluemix - Building a Project with Maven
IBM Bluemix - Building a Project with Maven
 
Jenkins.pptx
Jenkins.pptxJenkins.pptx
Jenkins.pptx
 
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/HudsonEclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
Eclipse DemoCamp Bucharest 2014 - Continuous Integration Jenkins/Hudson
 
XPages -Beyond the Basics
XPages -Beyond the BasicsXPages -Beyond the Basics
XPages -Beyond the Basics
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
 
Jenkins advance topic
Jenkins advance topicJenkins advance topic
Jenkins advance topic
 
Contineous integration
Contineous integrationContineous integration
Contineous integration
 
Louisville Software Engineering Meet Up: Continuous Integration Using Jenkins
Louisville Software Engineering Meet Up: Continuous Integration Using JenkinsLouisville Software Engineering Meet Up: Continuous Integration Using Jenkins
Louisville Software Engineering Meet Up: Continuous Integration Using Jenkins
 
Jenkins_1679702972.pdf
Jenkins_1679702972.pdfJenkins_1679702972.pdf
Jenkins_1679702972.pdf
 
jenkins.pdf
jenkins.pdfjenkins.pdf
jenkins.pdf
 
Intelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest IstanbulIntelligent Projects with Maven - DevFest Istanbul
Intelligent Projects with Maven - DevFest Istanbul
 
Devops
DevopsDevops
Devops
 
The Basic Concept Of IOC
The Basic Concept Of IOCThe Basic Concept Of IOC
The Basic Concept Of IOC
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 
Source version control using subversion
Source version control using subversionSource version control using subversion
Source version control using subversion
 
Bitbucket git-bamboo-jira
Bitbucket git-bamboo-jiraBitbucket git-bamboo-jira
Bitbucket git-bamboo-jira
 
Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...Symfony under control. Continuous Integration and Automated Deployments in Sy...
Symfony under control. Continuous Integration and Automated Deployments in Sy...
 
Symfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim RomanovskySymfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim Romanovsky
 

More from Viyaan Jhiingade (7)

Rate limiting
Rate limitingRate limiting
Rate limiting
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
No sql
No sqlNo sql
No sql
 
Rest Webservice
Rest WebserviceRest Webservice
Rest Webservice
 
Storm
StormStorm
Storm
 
Git commands
Git commandsGit commands
Git commands
 
Kafka RealTime Streaming
Kafka RealTime StreamingKafka RealTime Streaming
Kafka RealTime Streaming
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

Jenkins CI

  • 2. What is Continuous Integration?
  • 3. Continuous Integration • As defined by Martin Fowler • In software engineering CI implements continuous process of applying quality control – small pieces of effort applied frequently. • It aims to improve the quality of software and to reduce time taken to deliver. • This is done by replacing the traditional practice of applying quality control after completing development with continuous integration.
  • 4. What is CI? • What it is A development Methodology. A daily developer integration. Automated builds.
  • 5.
  • 8. Jenkins • Written in java • Runs inside servlet container. • Primarily written and developed by kosuke kawaguchi. • Split from Hudson. • Easy to install. • Over 600+ Plugins. • Can be scripted.
  • 10. Install Jenkins • Can be installed as 1. WAR 2. Native package. https://jenkins.io/download/
  • 11. First Jenkins Job • Start a Freestyle Job • Just build to execute one shell script. • Job will be named Hello World.
  • 12. • In the build section choose “Execute windows batch command”. From Add build steps. • Click Apply.
  • 13. • In command area type “echo hello world”. • Click save. • To run the build click Build Now.
  • 14. • The console output shows a temporary batch file created by Jenkins and execute by your behalf.
  • 16. Jenkins plugins Default Plugin Description ANT Use to run talk from build.xml Credentials To store Credentials in Jenkins JavaDoc Publishes Javadoc Junit Publishes junit test results Mailer Supports Mail Sending Subversion Supports SVN Maven Integration Integration Jenkins with maven. LDAP LDAP Authentication support
  • 18. Plugin Tabs Updates – Shows updates to already installed plugins. Available – Shows plugins that are available for installation. Installed – Shows plugins installed that have no problem. Advanced – Allows manual upload of plugins
  • 19. Pinning of Plugins • Plugins that are bundled or preinstalled with Jenkins can be pinned. • When Jenkins are updated all the plugins preinstalled are also updated. • But if any bundled plugin is manually updated it gets pinned to current version of Jenkins. • Update of Jenkins will not update this plugin. • /Plugins/plugin_name.jpi.pinned is created. • You can Unpin which means you are allowing the updates to happen.
  • 20. Global Tools • Manage Jenkins -> Global Tool Configuration • Configure tools, their locations and automatic installers.
  • 21. Automatic Install • Install automatically allows you to have custom installers or scripts. • Default is “Install from Apache” . • Else you can extract an already downloaded file.
  • 22. Maven Plugin • In addition to other env variable maven plugin makes below variables available to your jobs or scripts. • This plugin exposes variables found from the project's POM (as of version 2.1): • POM_DISPLAYNAME • POM_VERSION • POM_GROUPID • POM_ARTIFACTID • POM_PACKAGING
  • 23. Javadoc Plugin • Publishes your Javadoc if created by your build. • Maven Projects • Goal to run Javadoc:Javadoc • Freestyle Projects • Under “Add post-build action” -> Publish Javadoc
  • 24. HTML Publisher • Use to generate HTML files during the build. • You can publish PMD Reports, Java Docs etc.
  • 25. Git HUB • It allows you to connect Git Hub with Jenkins. • Trigger a build whenever push to repository happens.
  • 26. Git Hub Tokens • Goto Git Hub , log in, go to settings, personal access tokens , click on Generate new token. • Check repo:status • Click on Generate Token and copy it. • In Jenkins Management - > Configure System, Add a new GITHUB server config. • API URL: https://api.github.com • Check Manage Hooks Check box. • Click Add Button next to Credentials. • Enter Credentials in the dialog box( Screen 2)
  • 27. Configure GitHub – Screen 1 .
  • 29. Automatic Build when code is pushed • You will then have to tick the box indicated below – “Build when a change is pushed to GitHub”
  • 30. Contd. • Manage Jenkins -> Manage Plugins -> Available -> GitHub plugin • Copy the url in « Override Hook URL. And uncheck specify another hook url for GitHub Configurations.
  • 31. Contd. • The GitHub steps are pretty straight forward. Open the “Webhooks & Services” tab -> choose “Configure Services” -> find the Jenkins (GitHub plugin option) and fill it in with a similar URL to the following: • http://<Name of Jenkins server>:8080/github-webhook/
  • 32. Add WebHooks in Git Hub • The GitHub steps are pretty straight forward. Open the “Webhooks & Services” tab -> choose “Configure Services” -> find the Jenkins (GitHub plugin option) and fill it in with a similar URL to the following: • http://<Name of Jenkins server>:8080/github-webhook/
  • 33. Parameterised Builds • Allows user to provide parameters for Build in a URL. • Users are prompted to enter parameters before triggering build. • Exposes $Jenkins/job/$job/parambuild URL to trigger build with parameter.
  • 34. Credential Plugin • Provides convenient way to organize credentials across domains and maintains password secret once. • Used by other plugins indirectly when you are required to provide credentials. • There are multiple credentials plugin including. • Plain credentials • SSH Credentials • Google Oath • Dockers Common
  • 35. Credential Plugin • Kinds of Credentials • Username with password • SSH Username with private key • Certificate. • Scope of Credentials • Global- Available to the object on which credentials is associated and all objects that are children on that object. • System – Only available to object on which credentials is associated. Eg email
  • 36. Jenkins Copy Artifact • Allows you to copy artifacts built from other jobs into current workspace. • Select the option from Build Steps.
  • 37. Jenkins Copy Artifact (Contd) • Files matched by the "Artifacts to copy" field are copied to the same directory structure as the source build had You can use the "Flatten directories" option if you want the file(s) to be copied to the root of the build workspace. • Projects must enable “permission to copy Artifact” and select the project which is authorized to copy artifacts.
  • 38. • The location from which the artifacts are copied from is relative to: • - the artifacts folder, • - for the selected build, • - for the job you selected to copy from • So, first things first, you have to make sure that the job that you are copying from is actually archiving the artifacts. It will not copy files from workspace (there are other plugins for that). • To archive your artifacts, in the job the creates them, select post-build action "Archive the artifacts", then provide a list of artifacts you want to archive, relative to workspace. For example, to archive all zip files, regardless of where they are, use: **/*.zip • Or if you know that all your artifacts are inside the "build" folder, but there may be intermediate directories in between, use: build/**/*.zip • Or simply provide a full path: build/myartifactsfolder/myfile.zip Jenkins Copy Artifact (Contd)
  • 39. Jenkins Copy Artifact (Contd) • Now, to view the artifacts available, navigate in your browser to the URL of the job from which you want to copy, select the build you wish to copy from, and then append /artifact/ at the end, or just click "Build Artifacts" link on the page: example: http://localhost/job/YourJob/lastBuild/artifact/ • This will show a directory structure and all available artifacts. You can reference this in the "Copy Artifacts" post-build step directly. Or you can use wildcards. For example, if you want to ignore any directory structure, and just copy all *.zip files, your "Artifacts to copy" field should be: **/*.zip • The double stars ignore directories in between. You can use comma to separate multiple entries. Alternatively, if you leave this field blank, it will copy all available artifacts. • On the receiving end, the "Target directory" is relative to the Workspace of the job that is calling the "Copy Artifacts" step. • Lastly, if you don't care about the directory structure, check mark the "Flatten directories" option, so that all artifacts end up in the same place, ignoring any folders in between.
  • 40. Triggers • Manual Build • Click manually build now. • On Schedule • Use UNIX Cron rotation • Minutes • Hours • Day of month • Month • Day of week • When code changes in SCM • Polling SCM • Triggered on other builds.
  • 42. Cron Format • Jenkins uses UNIX Cron notation • Minutes (0-59) • * represents every value ***** means once every minute. • / allows you to skip e.g. */5 means every 5 minute. • Hours (0-23) • Commas represents list of values e.g. 2,3 means at 2 and 3 am in morning. • Day of month (1-31) • Month (1-12) • Day of week (0-7) • Ranges are allowed 1-5 means between Monday to Friday. 1. By setting the schedule period to 15 13 * * * you tell jenkins to schedule the build every day of every month of every year at the 15th minute of the 13th hour of the day. 2. If you want to schedule your build every 5 minutes, this will do the job : */5 * * * * 3. If you want to schedule your build every day at 8h00, this will do the job : 0 8 * * *
  • 43. Cron (Contd) • Jenkins lets you set up multiple times, separated by line breaks. • If you need it to build daily at 7am, along with every Sunday at 4pm, the below works well • H 7 * * * • H 16 * * 0
  • 44. Types of JOB • Maven • Free Style • Monitor an External Job • Multi Configurations jobs
  • 46. Maven vs FreeStyle • A maven project is a project that will analyze the pom.xml file in greater detail and produce a project that's geared towards the targets that are invoked. The maven project is smart enough to incorporate build targets like the javadoc or test targets and automatically setup the reports for those targets. There is little configuration required for it. See: http://wiki.hudson-ci.org/display/HUDSON/Building+a+maven2+project for more information on Maven project. • A Free-Style project is a project that can incorporate almost any type of build. While a maven project you can only build maven projects, the Free-Style project is the more "generic" form of a project. You can execute shell/dos scripts, invoke ant, and a lot more. Majority of the plugins are written to use the free-style project. The maven module is limited in that it can't invoke a shell script, or anything else just the maven targets. See: http://wiki.hudson-ci.org/display/HUDSON/Building+a+software+project for more information on a Free-Style project.
  • 49. Email
  • 50. Email
  • 51. Email Navigate to https://myaccount.google.com/lesssecureapps?pli=1 • Please enter your Gmail id when prompted while accessing the above url • Now turn on Allow less secure apps (This will enable your Gmail SMTP to interact with jenkins)
  • 52. Email / IRC integration Follow the steps as illustrated in previous slides Go to localhost:8080 (default port for Jenkins) Navigate to Manage Jenkins  Configure System Tick , Use SMTP Authentication Follow the details as per screenshot Give the username and password Tick, Use SSL Enter SMTP port Reply to address Charset Please enter a recipient email address Test by clicking on Test configuration
  • 53. Email Functionality • Default Email notification in Jenkins Post Build Action. • Email address can be separated by commas.
  • 54. Email (Contd) • Use Email Template management plugin if you don’t want use default one.
  • 56. User Access – Assign Roles to User
  • 57. Parameterization • Jenkins allows parameters to be set for builds. • While configuring job check the below option.
  • 58. Parameterization (Contd) • Simple Types • Boolean • Choice(Dropdown) • String • Text(Same as string but allow new lines) • Password(masked string) • Complex Types • File Parameters(Allows file to be uploaded) • Run parameters – Access past builds • Build Selector for copy artifact.
  • 59. Parameterization (Contd) • A parameterized job can be accessed by posting to • https://<yourserver>/job/$job/buildwithParameteres?PARAMETER=v alue
  • 60. Junit Test Report • Just make sure you build the maven with test profile.
  • 61. Health report amplification factor • The amplification factor to apply to test failures when computing the test result contribution to the build health score. • The default factor is 1.0 • A factor of 0.0 will disable the test result contribution to build health score. • A factor of 0.1 means that 10% of tests failing will score 99% health • A factor of 0.5 means that 10% of tests failing will score 95% health • A factor of 1.0 means that 10% of tests failing will score 90% health • A factor of 2.0 means that 10% of tests failing will score 80% health • A factor of 2.5 means that 10% of tests failing will score 75% health • A factor of 5.0 means that 10% of tests failing will score 50% health • A factor of 10.0 means that 10% of tests failing will score 0% health
  • 62. Contd
  • 63. Junit Test Report – Displaying test results
  • 66. Sample Report for PMD Plugin (Code Coverage tool)
  • 68. Maven and Code Coverage Tool Goals • For PMD:- pmd:pmd • For Corbertura:- cobertura:cobertura • For Find bugs :- findbugs:findbugs
  • 69. Cobertura Plugin – Post Build Actions
  • 71. Configure Pom.xml • To know how to configure pom.xml to set up code coverage tools. • Refer pom.xml of this project: https://github.com/Viyaan/JenkinsJobFlow
  • 72. HTML Validation • Install Unicorn Validator • In Build step select unicorn validator. • Enter the URL of site to validate.
  • 74. Backup and Restore • Install back up plugin.
  • 75. Set up for Backup Manager Plugin
  • 76. Backup Manager plugin parameters • Backup directory: A shared folder where back up is dumped. • Format: At what format it is dumped. • Verbose: Backup will be logged. • If you want to schedule your back periodically use thinBackup plugin.

Editor's Notes

  1. Tools can be either configured to be installed automatically or the path of the preinstalled tools can be specified.