0% found this document useful (0 votes)
41 views72 pages

Teja Devops

The document discusses different software development life cycle models including waterfall, V-shaped, prototype, spiral, iterative, and agile models. It also covers principles of agility and extreme programming practices like test-driven development, refactoring, and continuous integration.

Uploaded by

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

Teja Devops

The document discusses different software development life cycle models including waterfall, V-shaped, prototype, spiral, iterative, and agile models. It also covers principles of agility and extreme programming practices like test-driven development, refactoring, and continuous integration.

Uploaded by

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

AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Exercise-1
Software engineering and Agile software development

1.Get an understanding of the stages in software development lifecycle, the process models,
values and principles of agility and the need for agile software development. This will enable
you to work in projects following an agile approach to software development

Aim: understanding of the stages in software development lifecycle, the process models, values
and principles of agility and the need for agile software development

Procedure:

Software Development Life Cycle (SDLC)

Software Development Life Cycle (SDLC) is a framework that defines the steps involved in
the development of software at each phase. It covers the detailed plan for building, deploying
and maintaining the software. SDLC defines the complete cycle of development i.e. all the
tasks involved in planning, creating, testing, and deploying a Software Product.

SDLC Cycle

SDLC Cycle represents the process of developing software

Software Development Life Cycle Models


A software life cycle model is a descriptive representation of the software development cycle.
SDLC models might have a different approach but the basic phases and activity remain the
same for all the models.

Name :K.TEJASWAROOP
Roll no : 21HQ1A0529
Subject : CICD

1
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

1.Waterfall Model

Waterfall model is the very first model that is used in SDLC. It is also known as the linear
sequential model.In this model, the outcome of one phase is the input for the next phase.
Development of the next phase starts only when the previous phase is complete.

Advantages of the Waterfall Model:


1. Waterfall model is the simple model which can be easily understood and is the one in which
all the phases are done step by step.
2. Deliverables of each phase are well defined, and this leads to no complexity and makes the
project easily manageable.

2.V-Shaped Model

V- Model is also known as Verification and Validation Model. In this model Verification &
Validation goes hand in hand i.e. development and testing goes parallel. V model And Waterfall
model are the same except that the test planning and testing start at an early stage in V-Model.

Name :TEJASWAROOP
Roll no : 21HQ1A0529
Subject : CICD

2
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

3. Prototype Model

The prototype model is a model in which the prototype is developed prior to the actual
software.Prototype models have limited functional capabilities and inefficient performance
when compared to the actual software. Dummy functions are used to create prototypes. This is
a valuable mechanism for understanding the customers’ needs.

4. Spiral Model

The Spiral Model includes iterative and prototype approach.Spiral model phases are followed
in the iterations. The loops in the model represent the phase of the SDLC process i.e. the
innermost loop is of requirement gathering & analysis which follows the Planning, Risk
analysis, development, and evaluation. Next loop is Designing followed by Implementation &
then testing.

Name :TEJASWAROOP
Roll no : 21HQ1A0529
Subject : CICD

3
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

5. Iterative Model
Iterative process starts with a simple implementation of a subset of the software requirements
and iteratively enhances the evolving versions until the full system is implemented. At each
iteration, design modifications are made and new functional capabilities are added. The basic
idea behind this method is to develop a system through repeated cycles (iterative) and in smaller
portions at a time (incremental).

6. Big Bang Model ─ Design and Application

The Big Bang Model comprises of focusing all the possible resources in the software
development and coding, with very little or no planning. The requirements are understood and
implemented as they come. Any changes required may or may not need to revamp the complete
software.
This model is ideal for small projects with one or two developers working together and is also
useful for academic or practice projects. It is an ideal model for the product where requirements
are not well understood and the final release date is not given.

Name :TEJASWAROOP
Roll no : 21HQ1A0529
Subject : CICD

4
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

7. Agile model

Agile model believes that every project needs to be handled differently and the existing
methods need to be tailored to best suit the project requirements. In Agile, the tasks are divided
to time boxes (small time frames) to deliver specific features for a release.

AgilityPrinciples:
The Agile Alliance defines twelve lightness principles for those that need to attain agility:

1. Our highest priority is to satisfy the client through early and continuous delivery of valuable
computer software.

2. Welcome dynamical necessities, even late in development. Agile processes harness modification
for the customer’s competitive advantage.

3. Deliver operating computer software often, from a pair of weeks to a couple of months, with a
preference to the shorter timescale.

4. Business individuals and developers should work along daily throughout the project.

5. The build comes around actuated people. offer them the setting and support they have, and trust
them to urge the task done.

6. the foremost economical and effective methodology of conveyancing info to and among a
development team is face-to-face speech.

7. working computer software is the primary live of progress.

Name :TEJASWAROOP
Roll no : 21HQ1A0529
Subject : CICD

5
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

8. Agile processes promote property development. The sponsors, developers, and users got to be
able to maintain a relentless pace indefinitely.

9. Continuous attention to technical excellence and smart style enhances nimbleness


.
10. Simplicity—the art of maximizing the number of work not done—is essential.

11. the most effective architectures, necessities, and styles emerge from self– organizing groups.

12. At regular intervals, the team reflects on a way to become simpler, then tunes and adjusts its
behavior consequently.

Name :TEJASWAROOP
Roll no : 21HQ1A0529
Subject : CICD

6
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Exercise-2

Development & Testing with Agile: Extreme Programming

2. Get a working knowledge of using extreme automation through XP programming practices


of test first development, refactoring and automating test case writing.

Aim: a working knowledge of using extreme automation through XP programming practices


of test first development, refactoring and automating test case writing.

Software Engineering | Extreme Programming (XP)

Extreme programming (XP) is one of the most important software development frameworks of
Agile models. It is used to improve software quality and responsiveness to customer
requirements. The extreme programming model recommends taking the best practices that have
worked well in the past in program development projects to extreme levels.

Good practices need to be practiced in extreme programming: Some of the good practices
that have been recognized in the extreme programming model and suggested to maximize their
use are given below:

Code Review: Code review detects and corrects errors efficiently. It suggests pair
programming as coding and reviewing of written code carried out by a pair of programmers
who switch their works between them every hour
.
Testing: Testing code helps to remove errors and improves its reliability. XP suggests testdriven
development (TDD) to continually write and execute test cases. In the TDD approach, test
cases are written even before any code is written.

Incremental development: Incremental development is very good because customer feedback


is gained and based on this development team comes up with new increments every few days
after each iteration.

Simplicity: Simplicity makes it easier to develop good quality code as well as to test and debug
it.

Design: Good quality design is important to develop good quality software. So, everybody
should design daily.

Integration testing: It helps to identify bugs at the interfaces of different functionalities.


Extreme programming suggests that the developers should achieve continuous integration by
building and performing integration testing several times a day.

Name :TEJASWAROOP
Roll no : 21HQ1A0529
Subject : CICD

7
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Basic principles of Extreme programming

XP is based on the frequent iteration through which the developers implement User Stories.
User stories are simple and informal statements of the customer about the functionalities
needed. A User Story is a conventional description by the user of a feature of the required
system. It does not mention finer details such as the different scenarios that can occur. Based
on User stories, the project team proposes Metaphors.

Coding: The concept of coding which is used in the XP model is slightly different from
traditional coding. Here, the coding activity includes drawing diagrams (modeling) that will be
transformed into code, scripting a web-based system, and choosing among several alternative
solutions.

Testing: XP model gives high importance to testing and considers it to be the primary factor to
develop fault-free software.

Listening: The developers need to carefully listen to the customers if they have to develop
good quality software. Sometimes programmers may not have the depth knowledge of the
system to be developed. So, the programmers should understand properly the functionality of
the system and they have to listen to the customers.

Name :TEJASWAROOP
Roll no : 21HQ1A0529
Subject : CICD

8
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Designing: Without a proper design, a system implementation becomes too complex and very
difficult to understand the solution, thus making maintenance expensive. A good design results
elimination of complex dependencies within a system. So, effective use of suitable design is
emphasized.

Feedback: One of the most important aspects of the XP model is to gain feedback to understand
the exact customer needs. Frequent contact with the customer makes the development effective.

Simplicity: The main principle of the XP model is to develop a simple system that will work
efficiently in the present time, rather than trying to build something that would take time and
may never be used. It focuses on some specific features that are immediately needed, rather
than engaging time and effort on speculations of future requirements.

Pair Programming: XP encourages pair programming where two developers work together at
the same workstation. This approach helps in knowledge sharing, reduces errors andimproves
code quality.

Continuous Integration: In XP, developers integrate their code into a shared repository several
times a day. This helps to detect and resolve integration issues early on in the development
process.

Refactoring: XP encourages refactoring, which is the process of restructuring existing code to


make it more efficient and maintainable. Refactoring helps to keep the codebase clean,
organized and easy to understand.

Collective Code Ownership: In XP, there is no individual ownership of code. Instead, the
entire team is responsible for the codebase. This approach ensures that all team membershave
a sense of ownership and responsibility towards the code.

Planning Game: XP follows a planning game, where the customer and the development team
collaborate to prioritize and plan development tasks. This approach helps to ensure that the
team is working on the most important features and delivers value to the customer.

On-site Customer: XP requires an on-site customer who works closely with the development
team throughout the project. This approach helps to ensure that the customer’s needs are
understood and met, and also facilitates communication and feedback.

Name :TEJASWAROOP
Roll no : 21HQ1A0529
Subject : CICD

9
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Advantages of Extreme Programming (XP):


Slipped schedules − Timely delivery is ensured through slipping timetables and doable
development cycles.

Misunderstanding the business and/or domain − Constant contact and explanations are
ensured by including the client on the team.

Canceled projects − Focusing on ongoing customer engagement guarantees open


communication with the consumer and prompt problem-solving.

Staff turnover − Teamwork that is focused on cooperation provides excitement and


goodwill. Team spirit is fostered by multidisciplinary cohesion.

Costs incurred in changes − Extensive and continuing testing ensures that the modifications
do not impair the functioning of the system. A functioning system always guarantees that there
is enough time to accommodate changes without impairing ongoing operations.

Business changes − Changes are accepted at any moment since they are seen to be inevitable.

Production and post-delivery defects: Emphasis is on − the unit tests to find and repair bugs
as soon as possible.

Name :TEJASWAROOP
Roll no : 21HQ1A0529
Subject : CICD

10
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Exercise-3
Devops adoption in projects

3. It is important to comprehend the need to automate the software development lifecycle stages
through DevOps. Gain an understanding of the capabilities required to implement DevOps,
continuous integration and continuous delivery practices.

Aim: understanding of the capabilities required to implement DevOps, continuous integration


and continuous delivery practices

The practice of Modern Development is incomplete without mentioning Continuous


Integration, Continuous Deployment, and Continuous Delivery pipeline. This pipeline is one
of the best DevOps practices to deliver the code changes frequently and safely.
What is DevOps?
DevOps stands for development and operations. It’s a practice that aims at merging
development, quality assurance, and operations (deployment and integration) into a single,
continuous set of processes. This methodology is a natural extension of Agile and continuous
delivery approaches.]

DevOps Lifecycle
The DevOps lifecycle optimizes development processes from start to end and engages the
organization in continuous development, resulting in faster delivery times. This process mainly
consists of the following seven stages.

Subject : CICD

11
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Continuous Integration

Continuous Integration (CI) is a DevOps software development practice that enables the
developers to merge their code changes in the central repository. That way, automated builds
and tests can be run. The amendments by the developers are validated by creating a built and
running an automated test against them.

Continuous delivery
Continuous Delivery (CD) is a DevOps practice that refers to the building, testing, and
delivering improvements to the software code. The phase is referred to as the extension of the
Continuous Integration phase to make sure that new changes can be released to the customers
quickly in a substantial manner. Continuous Delivery gives you the power to decide whether
to make the releases daily, weekly, or whenever the business requires it. The maximum benefits
of Continuous Delivery can only be yielded if they release small batches, which are easy to

troubleshoot if any glitch occurs.

Continuous deployment
When the step of Continuous Delivery is extended, it results in the phase of Continuous
Deployment. Continuous Deployment (CD) is the final stage in the pipeline that refers to the
automatic releasing of any developer changes from the repository to the production.
Continuous Deployment ensures that any change that passes through the stages of production
is released to the end-users. There is absolutely no way other than any failure in the test that
may stop the deployment of new changes to the output. This step is a great way to speed up the
feedback loop with customers and is free from human intervention.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
12
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Continuous testing
Next in the DevOps lifecycle is the testing phase, wherein the developed code is tested for bugs
and errors that may have made their way into the code. This is where quality analysis (QA)
plays a major role in checking the usability of the developed software. Successful completion
of the QA process is crucial in determining whether the software meets the client’s
specifications .Automation tools, such as JUnit, Selenium, and TestNG, are used for continuous
testing, enabling the QA team to analyze multiple code-bases simultaneously. Doing this
ensures that there are no flaws in the functionality of the developed software.

Continuous monitoring
Monitoring the performance of a software product is essential to determine the overall efficacy
of the product output. This phase processes important information about the developed app.
Through continuous monitoring, developers can identify general patterns and gray areas inthe
app where more effort is required.Continuous monitoring is an operational phase where the
objective is to enhance the overall efficiency of the software application. Moreover, it monitors
the performance of the app as well. Therefore, it is one of the most crucial phases of the DevOps
lifecycle.

Continuous feedback
Continuous feedback is essential to ascertain and analyze the final outcome of the application.
It sets the tone for improving the current version and releasing a new version based on
stakeholder feedback. The overall process of app development can only be improved by
analyzing the results from the software operations. Feedback is nothing but information
gathered from the client’s end. Here, information is significant, as it carries all the data about
the performance of the software and its related issues. It also contains suggestions given by end
users of the software.

Continuous operations

The last stage in the DevOps lifecycle is the shortest and easiest to grasp. Continuity is at the
heart of all DevOps operations that helps automate release processes, allows developers to
detect issues quickly, and build better versions of software products. Continuation is key to
eliminate diversions and other extra steps that hinder development.Development cycles in
continuous operations are shorter, allowing organizations to advertise constantly and accelerate
the overall time to market the product. DevOps enhances the value of software products by
making them better and more efficient, thereby attracting new customers towards it.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
13
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Exercise-4
Implementation of CICD with Java and open source stack

4. Configure the web application and Version control using Git using Git commands and version
control operations.
Aim: Configure the web application and Version control using Git using Git commands and version control
operations.

Git is a version control system which lets we track changes we make to wer files over time.
With Git, we can revert to various states of wer files (like a time traveling machine). we can
also make a copy of our file, make changes to that copy, and then merge these changes to the
original copy. With Git, we can create an identical copy of that file and play around with the
navigation bar. Then, when we are satisfied with wer changes, we can merge the copy to the
original file. we are not limited to using Git just for source code files – we can also use it to
keep track of text files or even images. This means that Git is not just for developers – anyone
can find it helpful.

How to install Git


In order to use Git, we have to install it on wer computer. To do this, we can download the latest version
on the official website. we can download for wer operating system from the options given. we can also
install Git using the command line, but since the commands vary with each operating system, we'll
focus on the more general approach.

How to configure Git

I will assume that at this point we have installed Git. To verify this, we can run this command
on the command line: git --version. This shows we the current version installed on we PC. The
next thing we'll need to do is to set wer username and email address. Git will use this
information to identify who made specific changes to files.

git config –global user.name [name]


• Usage: For configuring the author name locally.
git config user.name [name]
• Usage: For configuring email addresses locally.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
14
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

git config user.email [email address]


Usage: For configuring email addresses globally

git init

This command is used to initialize a new git repository.


• Usage: For initialising a new git repository. How
to Create and Initialize a Project in Git

We are finally done with installing and setting up Git. It is now time to create our project. I
have created a folder on my desktop called Git and GitHub tutorial. Using the command line,
navigate to wer new project's location. For me, I would run the following commands:

git clone

This command is used to clone a remote git repository.


• Usage: For cloning a git repository.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
15
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

git add
This command is used to add files to the staging.

• Usage: For adding a particular file.

git add [filename]

• Usage: For add all files to staging.

git commit -m [message]


• Usage: For committing all the staged and unstaged changes till now. It is generally used when
you have already added your file changes to the staging area using the git add command and
need to add additional file changes to the the staging area with the commit.

git status

This command is used to lists all the committed files.


• Usage: For listing all the files that have been committee

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
16
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

git reset

This command is used to unstage a file from the staging area. • Usage: Unstage the files form
staging area while keeping the file changes. git reset • Usage: Reset a commit. git reset [commit
id

git log:This command is used for listing the version history of the current git branch. • Usage:
For listing the version history of the current branch:

git show :

This command is used to view the metadata and the file changes of a specific commit. Checking
the metadata and file changes of a commit:

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
17
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

git tag: This command is used to add a tag associated with a commit. Usage: Adding a tag to a
commit: git tag [commit id]

git branch: This command is used to create a branch from the current working directory. •
Usage: Creating a new branch

git checkout :This command is used for switching among different git branches. Checkout a git branch:
git checkout [branch name]
Create a new branch and switch into it: git checkout -b [branch name]

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
18
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

git remote: This command is used to connect the local git repository to the remote server.
•Usage: Connecting to the remote server: git remote add [variable name] [Remote Server Link]

git push :This command is used to send your staged changes to the remote repository. • Usage:

Commit the staged changes to the remote repository. git push [variable name] [remote repositry

name]

git pull: This command is used to get the changes in the remote repository and merge them to

the current working directory. • Usage: Pull changes from a remote repository: git pull [variable

name] [remote repositry name]

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
19
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

git stash

This command is used to temporarily store all the changed files in the working directory.
• Usage: Save all the modified tracked files temporarily: git stash
• Usage: List all the stashes: git stash list
• Usage: Delete the latest stash:

git fsck This command is used to check the integrity of the Git file system and it also helps in
identifying the corrupted objects.
• Usage: Integrity check of git file system:

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
20
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Exercise-5
Implementation of CICD with Java and open source stack

5. Configure a static code analyzer which will perform static analysis of the web application
code and identify the coding practices that are not appropriate. Configure the profiles and
dashboard of the static code analysis tool

AIM: static code analyzer which will perform static analysis of the web application code and
identify the coding practices that are not appropriate. Configure the profiles and dashboard of
the static code analysis tool

Procedure:
SONARQUBE INSTALLATION

WHAT IS A SONARQUBE?
SonarQube is an open source platform developed by SonarSource for continuous inspection of
code quality.
It is written in JAVA and supports 20+ programming languages.
FEATURES:
1. Not just tells what is wrong, also aids you to rectify via Quality Management tool.
2. Covers a greater stretch as far as definition of Quality is concerned (as proudly flaunt by its
developers
– Seven Axes of Quality), as compared to its competitors, whom major emphasis is on bugs &
complexity.
3. Its focus is not only just constraint to potential bugs or code conventions, but also extends
to span
coding standards, duplications, test coverage, unit testing, code complexity, API
documentation, architecture, comments, bugs along with providing details in a dashboard is
cherry on the top.
4. It provides metrics, tracking of which can help you to take right decision.
5. It provides various features to support Continuous Inspection practice, viz. Quality Gates,
Focus on leak, highlighting hotspots, branch analysis, analyze pull requests, visualizing the
history of project.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
21
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

SonarQube Installation steps:

Step 1:
Download the sonarqube software from
“ https://www.sonarqube.org/successdownloadcommunity-edition”
Step 2:
Extract the Zip file to the specific location Step
srtep 3:
Now open command prompt and change the directory to sonarqube bin upto windows 64 bit
installer

Step 4: Now type the command “StartSonar.bat” and now the SonarQube server will be started

Step 5: Now opensonarqube web server in browser by opening the following link
“http://localhost:9000” The screen appear as follows:

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
22
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Step 6: Initially login as admin and the password will also be admin.Later it asks for update
password.

Step 7: Now the SonarQbue dashboard will be opened .In dashboard click on create project
mannually.Then one screen will appear ,it asks for project name and project key so Specify
them.

Step 8: Then click on setup , select locally tab as shown in below figure.

Step 9: After clicking on locally block the screen appears as below and provide a token then
set expires days and click on “generate” key

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
23
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Step 10: The project name,project key and secret key are generated and save it at specific
location for futher use.

Step 11: Click on continue ,then one screen will appear and select the options as given below.

The sonarqube installed successfully and the project with token also created.To view the result
we have to install sonarQube-Scanner

SONAR SCANNER INSTALLATION

SonarScanner is a separate client type application that in connection with the SonarQube server
will run project
analysis and then send the results to the SonarQube server to process it. SonarScanner can
handle most

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
24
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

programming languages supported by SonarQube except C# and VB. It is usually located on


continuous integration agents (workers) or in separate docker images depending on your
project flow.

FEATURES:
It can provide information regarding:
duplicated code
coding standards
unit tests
code coverage
code complexity
comments

Step 1: Download the sonar scanner from this link


“https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/” The screen will be appear as follows:

Click on “windows 64-bit” and .exe file is downloaded


Step 2: Now Extract scanner to destination drive from .exe file and install it.
Step 3: Now set path in system environment variables upto bin and click on “OK” as shown in
below

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
25
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Step 4: Now download a project folder from https://github.com/SonarSource/sonar-scanningexamples

Step 5: sonarQube-scanner project folder has “sonar-project.properties” file and append


following content. Give the project name and generated token in sonar-project.properties file

Procedure of Static Code Analysis: Now open the command prompt and change the directory
to sonarQube-scanner project folder and execute the command “sonar-scanner.bat”

The project code is successfully analysed and the result is shared to the SonarQube dashboard

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
26
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Now open the static code analysis report in the SonarQube server dashboard.It will show the
parameters like
• No of bugs
• Vulnerabilities
• Code smell
• Duplicate lines and so on….
All these can be observed in the below figure

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
27
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Exercise -6

6Q: Write a build script to build the application using a build automation tool like Maven.
Create a folder structure that will run the build script and invoke the various software
development build stages. This script should invoke the static analysis tool and unit test cases
and deploy the application to a web application server like Tomcat ?

Aim: To implement a build script to build the application using a build automation tool like
Maven. Create a folder structure that will run the build script and invoke the various software
development build stages. This script should invoke the static analysis tool and unit test cases
and deploy the application to a web application server like Tomcat

Procedure:

Experiment unit testing maven junit and Jenkins


Fir you need login into Jenkins

Then click create new item


Give name test then press ok
Then select Source code management

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
28
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Then select git Add url https://github.com/teluguhackerforfree/maven.git

Add invoke top-level maven targets from add build step

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
29
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Goals tab add test


Then click appy and save Got dash board and run test job click on play button

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
30
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Select console output

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
31
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Exercise-7

7) Configure the Jenkins tool with the required paths, path variables, users and pipeline views?

Aim: To implement and Configure the Jenkins tool with the required paths, path variables,
users and pipeline views

Procedure:
What is Jenkins and why we use it?
Jenkins is an open-source automation tool written in Java with plugins built for Continuous
Integration
purposes. Jenkins is used to build and test your software projects continuously making it easier
for developers
to integrate changes to the project, and making it easier for users to obtain a fresh build. It also
allows you to continuously deliver your software by integrating with a large number oftesting
and deployment technologies.

Advantages of Jenkins include:


• It is an open-source tool with great community support. • It is easy to install.
• It has 1000+ plugins to ease your work. If a plugin does not exist, you can code it and share
it with the community.
• It is free of cost.
• It is built with Java and hence, it is portable to all the major platforms

Use AWS Cloud platform

Installation of Jenkins
Step1: create aws account

Step2:login to it

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
32
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Step3: create an instance

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
33
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
34
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
35
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
36
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
37
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Step5:creation of jenkins
installing java

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
38
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
39
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Manage Jenkins
To manage Jenkins, click on the ‘Manage Jenkins’ option from the left hand menu side. So one
can get the various configuration options for Jenkins by clicking the ‘Manage Jenkins’ option
from the left hand menu side. You will then be presented with the following screen −

Some of the management options are as follows −


Configure System
This is where one can manage paths to the various tools to use in builds, such as the JDKs, the
versions of Ant and Maven, as well as security options, email servers, and other system-wide
configuration details. When plugins are installed. Jenkins will add the required configuration
fields dynamically after the plugins are installed.
Reload Configuration from Disk
Jenkins stores all its system and build job configuration details as XML files which is stored in
the Jenkins home directory. Here also all of the build history is stored. If you are migrating
build jobs from one Jenkins instance to another, or archiving old build jobs, you will need to
add or remove the corresponding build job directories to Jenkins’s builds directory. You don’t
need to take Jenkins offline to do this—you can simply use the “Reload Configuration from
Disk” option to reload the Jenkins system and build job configurations directly.
Manage Plugin
Here one can install a wide variety of third-party plugins right from different Source
codemanagement tools such as Git, Mercurial or ClearCase, to code quality and
codecoverage metrics reporting. Plugins can be installed, updated and removed through the
Manage Plugins screen.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
40
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

System Information
This screen displays a list of all the current Java system properties and system environment
variables. Here one can check exactly what version of Java Jenkins is running in, what user it
is running under, and so forth. The following screenshot shows some of the name-value
information available in this section.
System Log
The System Log screen is a convenient way to view the Jenkins log files in real time. Again,
the main use of this screen is for troubleshooting.
Load Statistics
This pages displays graphical data on how busy the Jenkins instance is in terms of the number
of concurrent builds and the length of the build queue which gives an idea of how long your
builds need to wait before being executed. These statistics can give a good idea of whether
extra capacity or extra build nodes is required from an infrastructure perspective. Script
Console
This screen lets you run Groovy scripts on the server. It is useful for advanced troubleshooting
since it requires a strong knowledge of the internal Jenkins architecture.
Manage nodes
Jenkins is capable of handling parallel and distributed builds. In this screen, you can configure
how many builds you want. Jenkins runs simultaneously, and, if you are using distributed
builds, set up build nodes. A build node is another machine that Jenkins can use to execute its
builds.
Prepare for Shutdown
If there is a need to shut down Jenkins, or the server Jenkins is running on, it is best not to do
so when a build is being executed. To shut down Jenkins cleanly, you can use the Prepare for
Shutdown link, which preventsany new builds from being started. Eventually, when all of the
current builds have finished, one will be able to shut down Jenkins cleanly.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
41
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
42
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
43
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
44
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
45
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
46
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
47
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
48
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Exercise-8

8) Configure the Jenkins pipeline to call the build script jobs and configure to run it whenever
there is a change made to an application in the version control system. Make a change to the
background color of the landing page of the web application and check if the configured
pipeline runs ?

Aim: To Implement and configure the Jenkins pipeline to call the build script jobs and
configure to run it whenever there is a change made to an application in the version control
system. Make a change to the background color of the landing page of the web application and
check if the configured pipeline runs .

Procedure:

What is Jenkins Pipeline?


Jenkins Pipeline is a combination of plugins that supports integration and implementation of
continuous delivery pipelines. It has an extensible automation server to create simple
andcomplex delivery pipelines as code via pipeline DSL. A Pipeline is a group of events
interlinked with each other in a sequence.
What is Continuous Delivery Pipelines? How it Works?
In a Jenkins pipeline, every job or event has some sort of dependency on at least one or more
events.
Working of Jenkins Continuous Delivery Pipelines
Working of Jenkins Continuous Delivery Pipelines
The picture above represents a continuous delivery pipeline in Jenkins. It contains a group of
states called build, deploy, test and release. These events are interlinked with each other. Every
state has its events, which work in a sequence called a continuous delivery pipeline. A
continuous delivery pipeline is an automated expression to display your process for getting
software for version control. Thus, every change made in your software goes through a number
of complex processes on its way to being released. It also involves developing the software in
a reliable and repeatable manner, and progression of the built software through multiple stages
of testing and deployment.
What is a JenkinsFile?
Jenkins pipelines can be defined using a text file called JenkinsFile. You can implementpipeline
as code using JenkinsFile, and this can be defined by using a domain specific language (DSL).
With JenkinsFile, you can write the steps needed for running a Jenkins pipeline.

The benefits of using JenkinsFile are:

You can create pipelines automatically for all branches and execute pull requests with just one
JenkinsFile.
You can review your Jenkins code on the pipeline
You can audit your Jenkins pipeline
This is the singular source for your pipeline and can be modified by multiple users.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD
49
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

JenkinsFile can be defined by either Web UI or with a Jenkins File.

Declarative versus Scripted pipeline syntax:


There are two types of Jenkins pipeline syntax used for defining your JenkinsFile.
Declarative Scripted Declarative:
Declarative pipeline syntax offers an easy way to create pipelines. It contains a predefined
hierarchy to create Jenkins pipelines. It gives you the ability to control all aspects of a pipeline
execution in a simple, straightforward manner.
Scripted:
Scripted Jenkins pipeline runs on the Jenkins master with the help of a lightweight executor. It
uses very few resources to translate the pipeline into atomic commands. Both declarative and
scripted syntax are different from each other and are defined totally differently.
Install Build Pipeline Plugin in Jenkins
With the build pipeline plugin, you can create a pipeline view of incoming and outgoing jobs,
and create triggers which require manual intervention.
Here is how you can install the build pipeline plugin in your Jenkins:

Step 1)
The settings for the plugin can be found under Manage Jenkins>
Manage Plugins.
Installing Build Pipeline plugin in Jenkins
If you have already installed the plugin, it is shown under the installed tab.

Step 2)
If you do not have the plugin previously installed
it shows up under the Available tab.Once you have successfully installed the build pipeline
plugin in your Jenkins, follow these steps to create your Jenkins pipeline:

Subject : CICD

50
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Once you are logged in to your Jenkins dashboard:

Step 1) Click on the “+” button on the left-hand side of your Jenkins dashboard to create a
pipeline.

Step 2) You will be asked to give a name to the pipeline view. We shall call it “Guru99 Pipeline”
for the duration of this demo. Select Build a pipeline view under options Click ok.

Step 3) In the next page, you will be asked for some more details to configure your Jenkins
pipeline. Just accept the default settings, and make sure you choose the first job under the
settings.

Click on Apply and then OK.

Subject : CICD

51
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Create Jenkins Pipeline

Running a Pipeline build


Step 1: For running a pipeline build, you need to chain your jobs first. For this, go to your first
job and click on configure.

Step 2:
Now, under Build Triggers, check the Build after other projects are b

Thus, a chain for all your jobs has been created


Step 3:
Install the Build Pipeline view plugin if you don’t have it installed already.
Step 4:
Go to your Jenkins dashboard and create a view by clicking on the “+” button. Select the

Build PipelineView option and click OK.

Subject : CICD

52
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Users in Jenkins & Manage Permissions

The Role Strategy Plugin enable you to assign different roles and privileges to different
users. You will first need to install the plugin in your Jenkins mange
environment.Create/Add a User in Jenkins Below are the steps to create new user in
Jenkins:

Step 1: Login to Jenkins DashboardLogin to your Jenkins dashboard by visiting


http://localhost:8080/

If you haven’t installed Jenkins in your local server, go to the appropriate URL and access
yourdashboard by using your login credentials.

Step 2: Choose the optionYou will now see options to create and add user in Jenkins and
manage current users.
Step 3: Create a new UserUnder Manage Jenkins, Click Create UserEnter Jenkins add user
details like password, name, email etc. Click Create User

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

53
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Step 4: User is createdYou will see on the dashboard that a new Jenkins create user as per the
details entered.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

54
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Exercise-9

9) Create a pipeline view of the Jenkins pipeline used in Exercise 8. Configure it with user
defined messages?

Aim: To implement create a pipeline view of the Jenkins pipeline used in Exercise 8. Configure
it with user defined messages.
Procedure:
Step1: Select a folder which need to be pushed to Github repository.

Step 2: Follow the following procedure to push the files in desired repository.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

55
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Step 3: Open Jenkins and create new job by clicking on ‘New Item’.

Step 4: Give a unique name to job. Select ‘Freestyle project’ and then click on ‘OK’.

Step 5: After clicking ‘OK’, we will be directed to next step where we need to select ‘Git’ and
give URL ofour repository.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

56
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Step 6: Set Branch Specifier as ‘*/master’ if we have our file in it(of our mentioned repository).
With respect to the repository mention either ‘master’ or main.

If your codes are present in ‘master’ of Github then set master, otherwise ‘main’.

Step 7: Click on ‘Apply’ and then ‘Save’ the modification

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

57
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Step 8: Select ‘Java_file’ (our newly created job) and click on ‘Build Now’.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

58
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Step 9: Click on ‘Console Output’ to check our Java file’s output

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

59
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Exercise-10

10) In the configured Jenkins pipeline created in Exercise 8 and 9, implement quality gates
for static analysis of code?

STEP 1:
The sonarQube and sonarscanner has to be installed in your systems

STEP 2:
Open jenkins localhost Install the Jenkins Extension for SonarQube via the Jenkins Update Center.

STEP 3:
Configure your SonarQube server:
Log into Jenkins as an administrator and go to Manage Jenkins > Configure System

STEP 4:

Scroll down to the SonarQube configuration section, click Add SonarQube, and add the values
you're prompted for.enter the name(Any name) , provide localhost where sonarqube is running

STEP 5:
Global Configuration
This step is mandatory if you want to trigger any of your SonarQube analyses with the
SonarScanner. You can define as many scanner instances as you wish. Then for each
Jenkins job, you will be able to choose which launcher to use to run the SonarQube
analysis.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

60
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Log into Jenkins as an administrator and go to Manage Jenkins > Global Tool Configuration
Scroll down to the SonarScanner configuration section and click on Add SonarScanner. It is
based on the typical Jenkins tool auto-installation. You can either choose to point to an already
installed version of SonarScanner (uncheck 'Install automatically') or tell Jenkins to grab the
installer from a remote location (check 'Install automatically')

STEP 6:
Log into Jenkins as an administrator and go to Manage Jenkins>manage plugin and
installsonarQube scanner

STEP 7:

Create a PIPELINE JOB injenkins and move to pipeline option and select “pipeline script
from SCM”and provide github code link in Repository URL and credentials of your github
account

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

61
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

GITHUB CODE LINK:https://github.com/kumarimohana/java-web-app.git


STEP 8:
Add name as ‘Jenkinsfile’ in Script path

Now click on apply and save it

STEP 9:
Click on Build Now option and the job done successfully

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

62
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Exercise-11

11) In the configured Jenkins pipeline created in Exercise 8 and 9, implement quality
gates for static unit testing?

Aim: To implement In the configured Jenkins pipeline created in Exercise 8 and 9,


implement quality gates for static unit testing Procedure :

Jenkins - Unit Testing


Jenkins provides an out of box functionality for Junit, and provides a host of plugins for
unit testing for other technologies, an example being MSTest for .Net Unit tests. If you go
to the link https://wiki.jenkins- ci.org/display/JENKINS/xUnit+Plugin it will give the list
of Unit Testing plugins available.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

63
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

The following example will consider


• A simple HelloWorldTest class based on Junit.
• Ant as the build tool within Jenkins to build the class accordingly.
Step 1 − Go to the Jenkins dashboard and Click on the existing HelloWorld project and choose

option

the Configure

Step 2 − Browse to the section to Add a Build step and choose the option to Invoke Ant.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

64
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Step 3 − Click on the Advanced button.

Step 4 − In the build file section, enter the location of the build.xml file.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

65
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Step 5 − Next click the option to Add post-build option and choose the option of “Publish Junit
test result report

Step 6 − In the Test reports XML’s, enter the location as shown below. Ensure that Reports is
a folder which is created in the HelloWorld project workspace. The “*.xml” basically tells
Jenkins to pick up the result xml files which are produced by the running of the Junit test cases.
These xml files which then be converted into reports which can be viewed later.

Once done, click the Save option at the end.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

66
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Step 7 − Once saved, you can click on the Build Now option.

Once the build is completed, a status of the build will show if the build was successful or not.
In the Build output information, you will now notice an additional section called Test Result.
In our case, we entered a negative Test case so that the result would fail just as an example.

One can go to the Console output to see further information. But what’s more interesting is that
if you click on Test Result, you will now see a drill down of the Test results.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

67
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

68
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Exercise-12

Q: In the configured Jenkins pipeline created in Exercise 8 and 9, implement quality gates for
code coverage?

Aim: To implement In the configured Jenkins pipeline created in Exercise 8 and 9, implement
quality gates for code coverage

Procedure :

Let’s setup Quality Gates metrics in Sonar. We are going to create a quality gate only for the
metric called Code Coverage for demo purpose. But there are more metrics available that you
should be selecting while creating quality gates.

Login to sonar > got Quality Gates as shown in the screen below.

Quality Gate — screen shot in sonarqube

Click on create > Add Condition > Choose metrics (In this example, we selected Code
Coverage) > select operator along with warning and error threshold.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

69
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Create: Quality Gate

Select the project to add Quality Gates. We have selected a sample miqp project. In your case,
project name would be different so please change it accordingly.

Add project to Quality Gate

Now go to the Jenkins job and configure the Quality Gate validation.

Click on the job and go to Post-build Actions and provide the project details you have
associated with Quality Gate created in the earlier steps.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

70
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Post-build action — Enforce Quality Gates


We have configured the project key of miqp sample project along with Job status when sonar
analysis fails. Verify if our build fails after the quality check was enabled.

You can verify the same in the sonarqube server.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

71
AVANTHI’S RESEARCH AND TECHNOLOGICALACADEMY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Project status on Quality Gate

In the above screenshot, you can verify that the project miqp is reporting WARNING as the
code failed to meet the code coverage metric (i.e we set in one of the earlier steps).

Conclusion

In this article, we have shown how you can take your code analysis benefits to the next level
using Quality Gates. We also walked you through the process of setting up Quality Gates at
build level, using sonarqube and Jenkins.

This definitely helped the teams at MiQ by being on top of our quality control check and that
too in automated fashion. We are sure that this process can help you in your development
process as well.

Name :TEJA SWAROOP


Roll no : 21HQ1A0529
Subject : CICD

72

You might also like