NM RECORD
NM RECORD
SB8050-DEVOPS(2024-2025)
1
ABSTRACT
This project focuses on the integration of SonarQube, Jenkins, and Maven within a
DevOps pipeline to enhance the software development lifecycle by automating
build processes, ensuring code quality, and enabling continuous integration and
delivery (CI/CD). SonarQube, an open-source platform, is used for static code
analysis to detect bugs, vulnerabilities, and code smells, helping to maintain a high
standard of code quality. Jenkins, an automation server, orchestrates the CI/CD
pipeline by automating build, test, and deployment processes, ensuring efficient
software delivery. Maven is employed as the build automation tool to manage
dependencies, compile, test, and package the application. By combining these
tools, the project aims to streamline development, improve code quality, and
reduce manual errors, providing a scalable solution for modern software projects.
The integration of these tools allows for automated code inspection, continuous
feedback, and faster release cycles, ultimately leading to more reliable and efficient
software.
Continuous Integration and Continuous Deployment (CI/CD) are pivotal practices in
modern software development, enabling rapid and reliable software delivery
through automation. This project focuses on the implementation of a CI/CD
pipeline to streamline the development, testing, and deployment processes.
Continuous Integration (CI) involves automatically integrating code changes into a
shared repository, ensuring that the software is always in a buildable state. The CI
process is complemented by automated unit testing and static code analysis, which
detect errors early, improve code quality, and reduce the risk of defects. Continuous
Deployment (CD) goes a step further, automatically deploying the integrated code
to production or staging environments after successful testing, ensuring faster
release cycles and immediate delivery of features and bug fixes. By integrating tools
such as Jenkins for automation, SonarQube for code quality checks, and Maven for
build management, the CI/CD pipeline is designed to improve collaboration, reduce
manual intervention, and enhance software reliability. DevOps is a collaborative
software development approach that integrates development (Dev) and operations
(Ops) teams to streamline the software delivery process. This methodology
emphasizes a culture of collaboration, communication, and continuous
improvement among all stakeholders involved in the software development
lifecycle. DevOps aims to achieve faster and more reliable software delivery.
2
TABLE OF CONTENTS
S.NO EXERCISE PG.NO
3
EXERCISE:1 TESTING THE LAB ENVIRONMENT
OBJECTIVE
To test the lab environment by using the various bat files of the
software.
PROCEDURE
Step-(1)-open the edit environment variables menu from the windows search.
Then add the following varibles in the %Path% of your environment
variables.
Software Path to the bin directory
Java C:\Program Files\Java\jdk-1.8\bin
SonarQube C:\sonarqube-10.7.0.96327\bin\windows-x86-64
Jenkins C:\Program Files\Java\jdk-1.8\bin
Tomcat C:\Program Files\Apache Software Foundation\Tomcat 10.1\bin
Step-(2)-Start the all corresponding .bat files in the command line arguments.
Starting the SonarQube.
4
After the Installation of the jenkins.Check the jenkins dashboard at
localhost:8064
CONCLUSION:
The lab environment for the SonarQube,Jenkins and Tomcat has been Tested.
5
EXERCISE:2 GIT OPERATIONS
OBJECTIVE
To perform the Git operations from the eclipse using the eclipse Git plugin(Egit).
PROCEDURE
Step-(1)-login to your github repository.
6
CLONING OPERATION:
click on the clone a Git respository and copy the URL of your
repository.then enter your authentication details.
Click on next.
And the repository is cloned successfully in the eclipse.
Thus the cloning operation was successfully executed in the eclipse idle
through EGit.
PUSH OPERATION:
The push operation involves the pushing of the local project into the
github repo.
7
Right click on the project that you need to push into repository and then
click on the team option in that menu.
Under click on the share.
team→share
Click on finish.now the project state was changed into the staged state
from the master state.
COMMIT OPERATION:
8
Right click on the repository that you need to commit.
then click on the commit button.now it asks the username and password
enter your username and password ,then click on the login. the project is
now pushed into the repository and reflection in the github is shown
below.
CONCLUSION:
Thus the various Git commands are executed from the eclipse using EGit
plugin and output was verified.
9
EXERCISE:3 CREATING THE PROJECT IN SONARQUBE
OBJECTIVE
To create the simple project in the sonarqube.
PROCEDURE
Step-(1)-Download the sonarqube from the official website
www.sonarsource.com.
Step-(2)-Extract the zip folder into destination directory.
Step-(3)-set the path for the sonarqube as C:\sonarqube-
10.7.0.96327\bin\windows-x86-64 in your environmental varibles.
Step-(4)-To start the sonarqube open the cmd and type command
StartSonar.bat.
10
Then click on the log in button.
Step-(6)-Then the dashboard will be opened as follows.
Step-(8)-Enter the name of the project and the branch of the project.then
click on the next.
11
Step-(9)-Then choose your analyze method has locally
CONCLUSION
The project was created locally on the sonarqube and the
corresponding token was generated successfully.
12
EXERCISE:4 USING SONAR-RUNNER WITH
SONARQUBE
Click on continue.
Step-(3)-choose the option for analyze,Os and then copy the command
which is used to run the static analysis in the Sonar-Scanner.
13
Step-(4)-start the sonar-scanner in the root directory of the
project. Open the cmd in the project root directory,then run this
command in cmd.
sonar-scanner.bat -D"sonar.projectKey=sampleproject1" -
D"sonar.sources=." D"sonar.host.url=http://localhost:9000" -
D"sonar.token=sqp_9a01e5093725a3b0da83b465f83b540d0eb70682"
CONCLUSION
The project was created locally on the sonarqube and it is executed
generated successfully.
14
EXERCISE:5 CREATING A LOCAL REPOSITORY IN ARTIFACTORY
OBJECTIVE:
Understand creation of local repository in Artifactory
Local Repository
Step 4: To add the repository key, go to pom.xml and copy the <name> tag
value (Calc Dev Snapshot) as shown in the screenshot given below.
<modelVersion>4.0.0</modelVersion>
<name>My Application</name>
<url>http://www.example.com</url>
15
<version>2.7.0</version>
</parent>
<!-- Dependencies -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<ve
Step 6: You can view the binaries stored in the artifactory under Application->
Artifactory Packages
CONCLUSION:
local repository is created in artifactory in this
exercise.
16
EXERCISE:6 BUILD AUTOMATION USING MAVEN
OBJECTIVE:
To build the automation of the projects using the maven.
PROCEDURE:
Step-(1)- Install Apache Maven
17
Run unit tests:mvn test
CONCLUSION:
Thus the sample project was automated using the maven and commands
were executed.
18
EXERCISE:7 INSTALLATION & CONFIGURATION OF
JENKINS
OBJECTIVE
To install and configure the jenkins.
PROCEDURE
Step-(1)-Download the jenkins.exe from the official website jenkins.in
Step-(2)-Install the jenkins and set the port of the jenkins as 8064(TCP).
Step-(3)-login to the dashboard of the jenkins by using
http://localhost:8080.
19
Step-(5)-Under click on the system configuration.click on the tools and
configure the JDK as follows.
CONCLUSION:
Thus the jenkins was configured with the maven and JDK.
20
EXERCISE:8 INSTALLATION OF PLUGINS IN JENKINS
OBJECTIVE
To install the plugins in the jenkins.
PROCEDURE Step-(1)- login to the dashboard of the jenkins by
using http://localhost:8080.
• Visit Jenkins Plugin Index and download the .hpi or .jpi file for the
plugin.
CONCLUSION:
21
EXERCISE:9 CREATING CENTRAL PIPELINE
OBJECTIVE:
Creating main line CI pipeline .
PROCEDURE
Step-(1)-Create a new Folder item with name “Central_CI” using “New
Item” option as shown below. Add jobs of type Freestyle Project for each
of tasks needed in the the continuous integration pipeline.
22
Step-(2)- Create below mentioned job – Setup
CONCLUSION
23
EXERCISE:10 COPYING AND MOVING JOBS IN JENKINS
OBJECTIVE
To copy and move jobs in
jenkins
I. Copying Jobs:
Step 1: Click on the option of New Item from the left panel.
Step 2: Name the new job and enter the name of the job you wish to copy
below as shown:
CONCLUSION
24
EXERCISE 11: CREATING PIPELINE VIEW IN JENKINS
OBJECTIVE:
Understand creation of pipeline view in Jenkins
PROCEDURE
Step 1: Click on the ‘+’ symbol under the Jenkins project folder
as shown in the screenshot given below
CONCLUSION
Thus jobs are viewed in the pipeline view.
25
EXERCISE:12 CONFIGURE GATING CONDITIONS IN
JENKINS.
OBJECTIVE
Configure Gating Conditions In Jenkins.
PROCEDURE
1. Go to your Jenkinsfile.
2. Find the stage in the pipeline where you would like to raise a
change request. For example, before the ‘Production’
deployment stage.
We recommend adding 2 stages to your pipeline for deployment gating:
One stage to raise a change request, and another stage to check the status
of the change request.
3. Add the following snippet to your pipeline, replacing your Jira site name,
environment ID, environment type and service ID(s) you copied from your
Jira Service Management project.
stage('Request approval') { // Raise change
request steps {
echo 'Raise change request...'
jiraSendDeploymentInfo(site:'<YOUR-
SITE>.atlassian.net', environmentId:'us-prod-1',
environmentName:'us-prod-1',
environmentType:'production',
state:"pending",
enableGating:true,
serviceIds: [
'<YOUR-SERVICE-ID>'
]
)
}
}
stage("Approval gate") { // Check request
status steps {
retry(20) { // Poll every 30s
for 10min waitUntil {
sleep 30
checkGatingStatus(
26
site:'<YOUR-
SITE>.atlassian.net',
environmentId:'us-prod-1'
)
}
}
Snippet example: Raise gated change request
stage('Request approval') { // Raise change
request steps {
echo 'Raise change request...'
jiraSendDeploymentInfo(site:'<YOUR-
SITE>.atlassian.net', environmentId:'us-prod-
1', environmentName:'us-prod-1',
environmentType:'production',
state:"pending", // Deployment has not started yet
enableGating:true, // Notify Jira the pipeline is gated
serviceIds: [
'<YOUR-SERVICE-ID>'
]
)
}
}
Snippet example: Manually check change
request status
12
stage("Approval
gate") { steps
{ waitUntil
{
input message: "Check for approval?" // Manually trigger check
status checkGatingStatus(
27
site:'<YOUR-
SITE>.atlassian.net',
environmentId:'us-prod-1'
)
}
}
}
}
Snippet example: Automatically check change request status after a delay
stage("Approval
gate") { steps
{ waitUntil
{
sleep 30 // check status after 30s
checkGatingStatus(
site:'<YOUR-SITE>.atlassian.net',
environmentId:'us-prod-1'
)
}
}
}
}
Snippet example: Automatically check change request status (poll)
stage("Approval gate") {
steps {
retry(20) { // Retry every 30s
for 10min waitUntil {
sleep 30
checkGatingStatus(
site:'<YOUR-
SITE>.atlassian.net',
environmentId:'us-prod-1'
)
}
}
}
28
Full Jenkinsfile example
Raise a change request and wait for approval before deploying to production.
When the approval is complete, restart the pipeline automatically.
1 pipeline
{ agent
any
stages {
stage("Test
") {
steps {
echo "Deploying to test"
}
}
stage("Stage") {
steps {
echo "Deploying to staging"
}
}
stage('Request approval') { // Raise
change request steps {
echo 'Raise change request...'
jiraSendDeploymentInfo(site:'<YOUR-SITE>.atlassian.net',
environmentId:'us-prod-1',
environmentName:'us-prod-1',
environmentType:'production',
state:"pending",
enableGating:true,
serviceIds: [
'<YOUR-SERVICE-ID>'
]
)
}
}
stage("Approval gate") { // Check change request
status steps {
29
retry(20) { // Poll every 30s for 10min
waitUntil {
sleep 30
checkGatingStatus(
site:'<YOUR-
SITE>.atlassian.net',
environmentId:'us-prod-1'
)
}
}
}
}
stage("Production") {
steps {
echo "Deploying to production!!"
}
post {
always {
sh 'sleep 2'
}
// Notify Jira based on deployment
step result success {
jiraSendDeploymentInfo (
site: '<YOUR-SITE>.atlassian.net',
environmentId: 'us-prod-1',
environmentName: 'us-prod-1',
environmentType: 'production',
state: 'successful',
serviceIds: [
'<YOUR-SERVICE-ID>'
]
)
}
CONCLUSION
Thus the gating conditions are created in the
jenkins.
30