0% found this document useful (0 votes)
420 views

Jenkins Pipeline Project 4

1. The document discusses configuring a continuous integration/delivery pipeline for a Java web application project with source code in GitHub. 2. The pipeline includes jobs for developer compile, developer code review, QA unit testing, QA metrics checking, and packaging for deployment. 3. Each job is configured in Jenkins with the GitHub repository link, build trigger, job goal from the pom.xml file, and next job as the post-build action.

Uploaded by

ONLINE USAGE
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
420 views

Jenkins Pipeline Project 4

1. The document discusses configuring a continuous integration/delivery pipeline for a Java web application project with source code in GitHub. 2. The pipeline includes jobs for developer compile, developer code review, QA unit testing, QA metrics checking, and packaging for deployment. 3. Each job is configured in Jenkins with the GitHub repository link, build trigger, job goal from the pom.xml file, and next job as the post-build action.

Uploaded by

ONLINE USAGE
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 52

Build and Test Automation

using Jenkins Pipeline


Module 3: Build and Test Automation
Objectives of the
Session
1. Build SCM
2. Build Job Steps
1.1
3. Build Trigger Build Setup
4. Post Build Actions
5. Run your Build
6. Notification

1. Configure Test Reports 1. We will take a java


2. Run Test Cases Test 1.2 web application with
3. Display Results Automatio source code available
in GitHub.
n Jenkins 1 Build & Test 2 Class 2. It is a multi-module
maven project.
Manageme Projec 3. Demonstrate how to
1. Activating Security Automatio check-in/out code
Securin nt t using GIT
2. Identifying Jenkins
Users n 4. Build & run test
3. Authorization g 1.3 cases using Jenkins
4. Auditing Jenkins

1. E-mail Notification
Notification 1.4
System
Project
Snapshot
Project
Snapshot
Contact.java
Addressbook.java

Contactform.jav
a

ContactService.java
Delivery Pipeline for our
Project
Our project corresponds to scenario 4. Hence we will be building the delivery pipeline for our project as shown
below:
Develope Developer QA Unit Test QA
QA Package Deploy
r Code Case Metric
Compile Review Check
Where,
Build Job Description Plugin
Developer Compile Compiles the code pulled from GitHub repo NA
Review the compiled code to check whether the code meets
Developer Code Review PMD (Programming Mistake Detector)
the organization’s standard
QA Unit Test Perform unit test case JUnit
QA Metric Check Calculate the percentage of code accessed by testing Cobertura
QA Package Prepare a packaged code that can be deployed on any machine WAR build package
Deploy Specify the path to deploy the application NA

Each of the CI process in Jenkins for the above jobs will be discussed in the later sections of Module 2 and
Module 3
Configuring
pom.xml • To run a build, you need to specify its goal in the pom.xml file, present in GitHub
Repo

Let’s check the pom.xml file for the build jobs in our project:

Developer Compile
Developer Code The word specified in the <scope>
section should match with the job
Review QA Unit Test goal

QA Metric
Check QA
Package
Configuring
pom.xml Developer Code
Review

QA Unit Test
Developer Compile
Developer Code
Review QA Unit Test
QA Metric
Check QA
Package
For Developer Code Review, we use PMD (Programming The word specified in the <scope>
Mistake Detector) plugin. PMD is an inbuilt plugin in section should match with the job
Jenkins. Hence we do not specify its scope, instead we goal
provide its configuration details
Configuring
pom.xml QA Metric
Check

QA
Package

Developer Compile
Developer Code
Review QA Unit Test
QA Metric
Check QA
For QA Metric Check, we are using Cobertura plugin. For QA Package, maven sure fire plugin is responsible
Package Cobertura is an inbuilt plugin in Jenkins. Hence we do not for packaging the latest build that can be deployed on
specify its scope, instead we provide its configuration details any machine
Now we have
configured
the pom.xml file

Let’s start building our


jobs
Build a
Job The set of tasks to build the job are listed
below:

Specify the GitHub repo link to pull the code to Jenkins


GitHub Repo
Link
Specify the previous job that triggers the current job. Hence NA for 1st job
Build Trigger
Specify the testing action/goal for each job
Job Goal
Specify the next job/action to be triggered.
Post Build
Action
Demo Build a Job - Developer
Compile Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• Provide the GitHub path to checkout the code. Click Apply and
Review QA Unit Test Save.
QA Metric Check
QA Package & deploy
Demo Build a Job - Developer
Compile Action
GitHub Repo Link
Build Trigger - NA
Job Goal
Developer Compile Post Build Action
Developer Code
• Configure the Developer Compile job to compile the code in the build
Review QA Unit Test section
QA Metric Check
QA Package & deploy
Demo Build a Job - Developer
Compile Action
GitHub Repo Link
Build Trigger - NA
Job Goal
Developer Compile Post Build Action
Developer Code
• Once the Developer Compile process succeeds, the next job to be triggered is
Review QA Unit Test Developer
QA Metric Check Code Review

QA Package & deploy


Demo Build a Job - Developer Code
Review Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• Provide the GitHub path to checkout the code. Click Apply and
Review QA Unit Test Save.
QA Metric Check
QA Package & deploy
Demo Build a Job - Developer Code
Review Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• Developer Code Review is done when the compilation process succeeds. Hence the
Review QA Unit Test trigger
QA Metric Check job for Developer Code Review will be Developer Compile job

QA Package & deploy


Demo Build a Job - Developer Code
Review Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• Configure the Developer Code Review job to detect any errors in the code in build
Review QA Unit Test section
QA Metric Check
QA Package & deploy
Demo Build a Job - Developer Code
Review Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• Once the Developer Code Review is done, the next job to be triggered is QA Unit
Review QA Unit Test Test
QA Metric Check
QA Package & deploy
Demo Build a Job - QA Unit
Test Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• Provide the GitHub path to checkout the code. Click Apply and
Review QA Unit Test Save.
QA Metric Check
QA Package & deploy
Demo Build a Job - QA Unit
Test Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• QA Unit Test is done when the code review succeeds. Hence the trigger job for QA Unit Test
Review QA Unit Test will be Developer Code Review job
QA Metric Check
QA Package & deploy
Demo Build a Job - QA Unit
Test Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• Configure the QA Unit Test job to run unit test cases in build
Review QA Unit Test section
QA Metric Check
QA Package & deploy
Demo Build a Job - QA Unit
Test Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• Once the testing is done, the next job to be triggered is QA Metric
Review QA Unit Test Check
QA Metric Check
QA Package & deploy
Demo Build a Job - QA Metric
Check Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• Provide the GitHub path to checkout the code. Click Apply and
Review QA Unit Test Save.
QA Metric Check
QA Package & deploy
Demo Build a Job - QA Metric
Check Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• QA Metric Check is done when the QA Test is succeeded. Hence the trigger job for
Review QA Unit Test QA
QA Metric Check Metric Check will be QA Unit Test

QA Package & deploy


Demo Build a Job - QA Metric
Check Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• Configure the QA Metric Check to calculate the percentage of code accessed by testing
Review QA Unit Test in
QA Metric Check build section

QA Package & deploy


Demo Build a Job - QA Metric
Check Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• Once the QA Metric Check is done, we have to build a QA Package that can be deployed
Review QA Unit Test on
QA Metric Check any machine

QA Package & deploy


Demo Build a Job - QA
Package Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• Provide the GitHub path to checkout the code. Click Apply and
Review QA Unit Test Save.
QA Metric Check
QA Package & deploy
Demo Build a Job - QA
Package Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• QA Package is formed when the QA Metric Check succeeds. Hence the trigger job for
Review QA Unit Test QA
QA Metric Check Package will be QA Metric Check

QA Package & deploy


Demo Build a Job - QA
Package Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• Configure the QA Package to develop a final project package that can be deployed on
Review QA Unit Test any
QA Metric Check machine

QA Package & deploy


Demo Build a Job - QA
Package Action
GitHub Repo Link
Build Trigger
Job Goal
Developer Compile Post Build Action
Developer Code
• Once the QA Package job succeeds, you need to archive the latest build so that it can
Review QA Unit Test be
QA Metric Check used when required and you use this package to be deployed on any machine

QA Package & deploy


Demo Run Build
Pipeline • Once you configure your builds, you need to run tests to create a delivery
pipeline

Step 1: Install the Build Pipeline Plugin

Run Test Cases


Display Step 2: Create an additional tab in your Jenkins homepage to have a graphical view of
the
Results test cases that are run (you can also see the console output here)
Demo Run Build
Pipeline Step 3: Set the number of builds to be displayed and from where to run the
build jobs

Configure Test
Reports
Run Test Cases
Run Test Cases
Display
Display
Results
Results
Demo Run Build
Pipeline Step 4: Below screen shows the graphical representation of the build. Click on
run.

Configure Test
Reports
Run Test Cases
Run Test Cases Step 5: Your build starts
Display
Display executing
Results
Results
Demo Run Build
Pipeline Step 6: You can also see the console output by clicking on the highlighted
button

Configure Test
Reports
Run Test Cases
Run Test Cases
Display
Display
Results
Results
Demo Run Build
Pipeline Step 7: Once the build runs successfully, all the jobs in the delivery pipeline turns
green

Configure Test
Reports
Run Test Cases
Run Test Cases
Display
Display
Results
Results
Demo Display
Results Build Job Result
Developer Compile Compilation
Developer Code Review PMD Test Report
QA Unit Test Unit Test Case Report
QA Metric Check Cobertura Report

Configure Test QA Package WAR build Package


Reports
Run Test Cases The compilation results can be viewed in the console
Run Test Cases output
Display
Display
Results
Results
Demo Display
Results Build Job Result
Developer Compile Compilation
Developer Code Review PMD Test Report
QA Unit Test Unit Test Case Report
QA Metric Check Cobertura Report

Configure Test QA Package WAR build Package


Reports
Run Test Cases You can also view the warnings returned for any build, by clicking on the
Run Test Cases PMD
Display
Display Results in the Jenkins Homepage
Results
Results
Demo Display
Results Build Job Result
Developer Compile Compilation
Developer Code Review PMD Test Report
QA Unit Test Unit Test Case Report
QA Metric Check Cobertura Report

Configure Test QA Package WAR build Package


Reports
Run Test Cases You can also view the number of test cases, their status, the duration and their
Run Test Cases status
Display
Display
Results
Results
Demo Display
Results Build Job Result
Developer Compile Compilation
Developer Code Review PMD Test Report
QA Unit Test Unit Test Case Report
QA Metric Check Cobertura Report

Configure Test QA Package WAR build Package


Reports
Run Test Cases You can also view the cobertura test results for the QA Metric
Run Test Cases Check
Display
Display
Results
Results
Demo Display
Results Build Job Result
Developer Compile Compilation
Developer Code Review PMD Test Report
QA Unit Test Unit Test Case Report
QA Metric Check Cobertura Report

Configure Test QA Package WAR build Package


Reports
Run Test Cases You will find the QA deployable package in the QA Package Jenkins
Run Test Cases screen
Display
Display
Results
Results
Security in
Jenkins
1. Activating Security
2. Identifying Jenkins
Users
3. Authorization
4. Auditing
Activating
Security • Immediately after installation, Jenkins will allow anyone to run, which is
dangerous.
• Jenkins supports several security models, and can integrate with several
user repositories like LDAP.
• In larger organizations, certain build jobs may be visible to all users whereas
others will need to be hidden to unauthorized users. Thus we need security.
Activating Security • To activate security, go to Configure Global Security and check the enable
Identifying Jenkins security option
Users Authorization
Auditing
Identify Jenkins
Users • Here, we establish the user authentication
• For smaller & informal installations, you can allow Jenkins to maintain it’s own
user database
• For enterprise installations, you will want to use your corporate service, which
allows users to log in to Jenkins with their organization’s username and
password.

Activating Security
Identifying Jenkins
Users Authorization
Auditing
Identify Jenkins
Users • Delegate to servlet container:
• Used when you run Jenkins on a Servlet container such as Tomcat or
GlassFish
• Here you integrate the Servlet container with local enterprise user directory.

Activating Security • GitHub Authentication Plugin: Dedicated for GitHub users only

Identifying Jenkins • Jenkins own user database:


• Authenticate the internal user name/password
Users Authorization
database
Auditing
• LDAP (Lightweight Directory Access Protocol)
• Jenkins authenticate users using the LDAP repository, check group
membership,
and retrieve the email address of authenticated users.
Authorizatio
n • Authorization, determines what users can do once they are logged in
• This ranges from simple options like “Anyone can do anything” or “Logged-
in users can do anything”

Activating Security
Identifying Jenkins
Users Authorization
Auditing
Authorizatio
n • Legacy mode
• Admin - Full control of the system
• Others - Only have the read
access.
• Matrix based security: Here, you can configure who can do what by using a
Activating Security big table.

Identifying Jenkins
Users Authorization
Auditing • Project based matrix authorization strategy
• First you provide access and then add users/groups for the
project.
Auditin
g • Jenkins also keeps track of the individual user actions: who did what to
server configuration.

Step 1: Install the audit trail plugin. The Audit Trail Plugin keeps track of the
main user actions in a set of rolling log files.

Activating Security
Identifying Jenkins
Users Authorization
Auditing
Auditin
g Step 2: Indicate the directory in which the log files are to be
written.

Activating Security
Identifying Jenkins
Users Authorization
Auditing
Notification
Management
E-mail Notification
E-mail
Notification
• The premium feature of the Jenkins server is to let people know when a build
breaks.
• Email notification is the most obvious and most common form of CI notification.

Step 1: Install the “Email Ext” plugin


E-mail
Notification
Step 2: Provide SMTP
details
E-mail
Notification
Step 3: Enter the email addresses of the team members to notify about the build status. Jenkins will
send an email message to those users
Thank You

Slide 67

You might also like