Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c25c963
jenkins userdata
devopshydclub Jul 1, 2023
1dc4db6
Update nexus-setup.sh
hkhcoder Jul 1, 2023
c757e03
Update pom.xml
hkhcoder Oct 16, 2023
d98cb9e
Create settings.xml
hkhcoder Oct 16, 2023
0f8fd84
Update pom.xml
hkhcoder Nov 3, 2023
cd14391
Update pom.xml
hkhcoder Nov 3, 2023
55e76b9
Update nexus-setup.sh with jdk17
hkhcoder Aug 19, 2024
6dde3d2
Update jenkins-setup.sh
hkhcoder Jan 16, 2025
32b4f26
Update nexus-setup.sh
hkhcoder Mar 5, 2025
2afe12b
Upgraded Jenkins File
Punee48 Feb 5, 2026
976f94d
Refactor Jenkinsfile for improved formatting and consistency
Punee48 Feb 5, 2026
94acfcb
Fix formatting of repository IDs in settings.xml for consistency
Punee48 Feb 5, 2026
495d763
Fix typo in SONAR_SCANNER environment variable name in Jenkinsfile
Punee48 Feb 5, 2026
147c040
Add SONAR_SCANNER_OPTS to resolve Java 17 compatibility issues
Punee48 Feb 5, 2026
5911c0d
Add SONAR_SCANNER_OPTS to resolve Java 17 compatibility issues in Son…
Punee48 Feb 5, 2026
394ecbd
Add Quality Gates stage to Jenkins pipeline and update README with Qu…
Punee48 Feb 5, 2026
aeb945a
Add stage to upload artifacts to Nexus and update README with artifac…
Punee48 Feb 5, 2026
2da0efe
Add email notification for pipeline completion status
Punee48 Feb 5, 2026
fb4fab4
Update email notification to include build status and job details
Punee48 Feb 5, 2026
45247ac
Increase timeout value in ansible configuration from 30 to 35 seconds
Punee48 Feb 5, 2026
3aa2213
Add Ansible deployment stage and update README with deployment instru…
Punee48 Feb 9, 2026
20a0002
Fix syntax in Ansible deployment stage by adding a comma for clarity
Punee48 Feb 9, 2026
14e91c5
Fix artifact URL in Ansible deployment script to include artifactId f…
Punee48 Feb 9, 2026
801aefa
Fix destination path for downloading VProfile.war in Ansible setup
Punee48 Feb 9, 2026
4711ba2
Fix spacing in source path for deploying VProfile artifact in Ansible…
Punee48 Feb 9, 2026
221dff9
Fix indentation for destination path in Ansible setup for VProfile ar…
Punee48 Feb 9, 2026
403f73b
Final Update for this Branch
Punee48 Feb 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ansible.python.interpreterPath": "/bin/python3"
}
189 changes: 109 additions & 80 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,121 +1,150 @@
pipeline {

agent any
/*
tools {
maven "maven3"
// Agent we will use any Agent Node in the Jenkins to run this pipeline
agent any

tools {
// Mention the Tool configured in the Jenkins Server like Java, Maven, Git
maven 'Maven_Tool'
jdk 'Java_Tool'
}
*/

// Set Environment Variable for the Nexus to interact to download the dependencies and upload artifacts in the Nexus
environment {
NEXUS_VERSION = "nexus3"
NEXUS_PROTOCOL = "http"
NEXUS_URL = "172.31.40.209:8081"
NEXUS_REPOSITORY = "vprofile-release"
NEXUS_REPO_ID = "vprofile-release"
NEXUS_CREDENTIAL_ID = "nexuslogin"
ARTVERSION = "${env.BUILD_ID}"

NEXUS_USER = 'admin'
NEXUS_PASS = 'admin'
RELEASE_REPO = 'vprofile-release'
CENTRAL_REPO = 'vprofile-maven-central'
SNAP_REPO = 'vprofile-snapshot'
NEXUS_GRP_REPO = 'vprofile-maven-group'
NEXUSIP = '172.31.32.231'
NEXUSPORT = '8081'
NEXUS_LOGIN = 'NEXUS_CREDENTIALS'
SONAR_SCANNER = 'sonarqubescanner'
SONAR_SERVER_LOGIN = 'sonarserver'
NEXUS_CRED = credentials('Nexus_Login')

}

stages{

stage('BUILD'){

stages {
stage('Build Applications') {
steps {
sh 'mvn clean install -DskipTests'
sh 'mvn -s settings.xml -DskipTests install' // Run Install and use setting.xml file and skip unit test
}
post {
success {
echo 'Now Archiving...'
archiveArtifacts artifacts: '**/target/*.war'
echo 'Now Archiving'
archiveArtifacts artifacts: '**/*.war'
}
}
}

stage('UNIT TEST'){
// Test Application
stage('Test Application') {
steps {
sh 'mvn test'
}
}

stage('INTEGRATION TEST'){
steps {
sh 'mvn verify -DskipUnitTests'
}
}

stage ('CODE ANALYSIS WITH CHECKSTYLE'){
// Check Style Application for Vulnerability scan
stage('CheckStyle for the Application') {
steps {
sh 'mvn checkstyle:checkstyle'
}
post {
success {
echo 'Generated Analysis Result'
}
}
}

stage('CODE ANALYSIS with SONARQUBE') {

environment {
scannerHome = tool 'sonarscanner4'
}
// Upload Report to the Sonar Server to check the Vulnerability. Refer Documentation for code
stage('Sonar Qube Analysis') {
environment {
scannerhome = tool "${SONAR_SCANNER}" // Mention the name used while configuring sonarscanner in the jenkins tools
// ADD THIS LINE BELOW to fix the Java 17 error

SONAR_SCANNER_OPTS = "--add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED"
}

steps {
withSonarQubeEnv('sonar-pro') {
sh '''${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \

steps {
withSonarQubeEnv("${SONAR_SERVER_LOGIN}") {
sh '''${scannerhome}/bin/sonar-scanner -Dsonar.projectKey=vprofile \
-Dsonar.projectName=vprofile-repo \
-Dsonar.projectVersion=1.0 \
-Dsonar.sources=src/ \
-Dsonar.java.binaries=target/test-classes/com/visualpathit/account/controllerTest/ \
-Dsonar.junit.reportsPath=target/surefire-reports/ \
-Dsonar.jacoco.reportsPath=target/jacoco.exec \
-Dsonar.java.checkstyle.reportPaths=target/checkstyle-result.xml'''
}
}

timeout(time: 10, unit: 'MINUTES') {
waitForQualityGate abortPipeline: true
}
stage('Validate Quality Gates') {
steps {
//timeout is 1 hrs
timeout(time: 1, unit: 'HOURS') {
waitForQualityGate abortPipeline: true
}
}
}
}

stage("Publish to Nexus Repository Manager") {
// Upload Artifacts to the Nexus Repos
stage('Upload Artifacts') {
steps {
script {
pom = readMavenPom file: "pom.xml";
filesByGlob = findFiles(glob: "target/*.${pom.packaging}");
echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}"
artifactPath = filesByGlob[0].path;
artifactExists = fileExists artifactPath;
if(artifactExists) {
echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version ${pom.version} ARTVERSION";
nexusArtifactUploader(
nexusVersion: NEXUS_VERSION,
protocol: NEXUS_PROTOCOL,
nexusUrl: NEXUS_URL,
groupId: pom.groupId,
version: ARTVERSION,
repository: NEXUS_REPOSITORY,
credentialsId: NEXUS_CREDENTIAL_ID,
artifacts: [
[artifactId: pom.artifactId,
classifier: '',
file: artifactPath,
type: pom.packaging],
[artifactId: pom.artifactId,
classifier: '',
file: "pom.xml",
type: "pom"]
]
);
}
else {
error "*** File: ${artifactPath}, could not be found";
}
}
nexusArtifactUploader(
nexusVersion: 'nexus3',
protocol: 'http',
nexusUrl: "${NEXUSIP}:${NEXUSPORT}",
groupId: 'QA',
version: "${env.BUILD_ID}-${env.BUILD_TIMESTAMP}",
repository: "${RELEASE_REPO}",
credentialsId: "${NEXUS_LOGIN}",
artifacts: [
[artifactId: 'vproapp',
classifier: '',
file: 'target/vprofile-v2.war',
type: 'war']
]
)
}
}

stage('Ansible Deployment in App Stagging Server') {
steps {
ansiblePlaybook(
playbook: 'ansible/site.yml', // In this File we have used Import command to import the other playbooks
inventory: 'ansible/inventory',
credentialsId: 'SSHKEY_APP_STAG', // Cred ID of the SSH Key used to connect to the app stagging server
colorized: true,
installation: 'ansible',
disableHostKeyChecking: true, // Means Jenkins will not check for the host key verification while connecting to the server
extraVars:
[
USER: 'admin',
PASS: "${NEXUS_CRED}",
nexusip: "${NEXUSIP}",
reponame: 'vprofile-release',
groupid: 'QA',
time: "${env.BUILD_TIMESTAMP}",
build: "${env.BUILD_ID}",
vprofile_version: "${env.BUILD_ID}-${env.BUILD_TIMESTAMP}",
artifactId: 'vproapp'

]
)
}
}
}


}
// Email Notification Of the Status of Pipeline
post {
always {
echo 'Pipeline has been completed Sending Pipeline Status through Email...'
emailext (
body: """<p>Jenkins Build Status: <b>${currentBuild.currentResult}</b></p>
<p>Job Name: ${env.JOB_NAME}</p>
<p>Build Number: ${env.BUILD_NUMBER}</p>
<p>Check console output at: <a href='${env.BUILD_URL}'>${env.BUILD_URL}</a></p>""",
subject: "Jenkins Build ${currentBuild.currentResult}: Job ${env.JOB_NAME} | ${env.BUILD_NUMBER}",
to: 'puneethkumar482000@gmail.com'
)
}
}
}
Loading