Skip to content
Open

pr1 #225

Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM maven:3.9-eclipse-temurin-17 AS build
WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN mvn clean package -DskipTests

# web.xml declares Servlet 2.5 (javax.servlet), but pom.xml actually pulls in
# Spring 6 / Boot 3.1, which is Jakarta-only (jakarta.servlet.*) — the real
# classes on the classpath, not the stale web.xml schema attribute, determine
# the runtime requirement. Tomcat 9 has no jakarta.servlet.* at all, which
# throws NoClassDefFoundError on Spring's ContextLoaderListener. Tomcat 10+
# ships jakarta.servlet.* and deploys an old-schema web.xml fine regardless.
FROM tomcat:10.1-jdk17-temurin
COPY --from=build /app/target/*.war /usr/local/tomcat/webapps/ROOT.war
EXPOSE 8080
128 changes: 24 additions & 104 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,122 +1,42 @@
pipeline {

agent any

tools {
jdk "JDK17"
maven "MAVEN3.9"
}

agent any

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}"
HARBOR_HOST = '192.168.56.20'
IMAGE = "${HARBOR_HOST}/vprofile/vproapp"
TAG = "${env.BUILD_NUMBER}"
KUBECONFIG = '/var/lib/jenkins/.kube/config'
}

stages{

stage('BUILD'){
steps {
sh 'mvn clean install -DskipTests'
}
post {
success {
echo 'Now Archiving...'
archiveArtifacts artifacts: '**/target/*.war'
}
}
}

stage('UNIT TEST'){
stages {
stage('Build image') {
steps {
sh 'mvn test'
sh "docker build -t ${IMAGE}:${TAG} -t ${IMAGE}:latest ."
}
}

stage('INTEGRATION TEST'){
stage('Push to Harbor') {
steps {
sh 'mvn verify -DskipUnitTests'
sh '''
set -a; . /etc/harbor-creds.env; set +a
echo "$HARBOR_PASS" | docker login "$HARBOR_HOST" -u "$HARBOR_USER" --password-stdin
'''
sh "docker push ${IMAGE}:${TAG}"
sh "docker push ${IMAGE}:latest"
}
}

stage ('CODE ANALYSIS WITH CHECKSTYLE'){
steps {
sh 'mvn checkstyle:checkstyle'
}
post {
success {
echo 'Generated Analysis Result'
}
}
}

stage('CODE ANALYSIS with SONARQUBE') {

environment {
scannerHome = tool 'sonarscanner4'
}

steps {
withSonarQubeEnv('sonar-pro') {
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("Publish to Nexus Repository Manager") {
stage('Deploy to Kubernetes') {
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";
}
}
sh "kubectl -n vprofile set image deployment/vproapp vproapp=${IMAGE}:${TAG}"
sh "kubectl -n vprofile rollout status deployment/vproapp --timeout=180s"
}
}


}


post {
always {
sh 'docker image prune -f || true'
}
}
}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Prerequisites
#

- JDK 17 or 21
- Maven 3.9
- MySQL 8

# Technologies
- Spring MVC
- Spring Security
- Spring Security
- Spring Data JPA
- Maven
- JSP
Expand All @@ -20,6 +20,6 @@ Here,we used Mysql DB
sql dump file:
- /src/main/resources/db_backup.sql
- db_backup.sql file is a mysql dump file.we have to import this dump to mysql db server
- > mysql -u <user_name> -p accounts < db_backup.sql


- > mysql -u <user_name> -p accounts < db_backup.sql.
1 change: 1 addition & 0 deletions ansible/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hi