Skip to content
Open
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
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM openjdk:17-jdk-slim


WORKDIR /app


COPY target/spring-boot-2-hello-world-1.0.2-SNAPSHOT.jar app.jar


EXPOSE 8080


ENTRYPOINT ["java", "-jar", "app.jar"]
50 changes: 50 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
pipeline {
agent any

environment {
SONARQUBE_ENV = 'MySonarQube'
}

stages {
stage('Checkout') {
steps {
checkout scm
}
}

stage('Build with Maven') {
steps {
sh 'mvn clean package -DskipTests'
}
}

stage('SonarQube Analysis') {
steps {
withSonarQubeEnv("${SONARQUBE_ENV}") {
sh 'mvn sonar:sonar'
}
}
}

stage('Quality Gate') {
steps {
waitForQualityGate abortPipeline: true
}
}

stage('Archive JAR') {
steps {
archiveArtifacts artifacts: 'target/*.jar', fingerprint: true
}
}
}

post {
success {
echo "JAR built, analyzed by SonarQube, and archived successfully."
}
failure {
echo "Build failed due to errors or Quality Gate failure."
}
}
}
21 changes: 21 additions & 0 deletions deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: helloworld-deployment
namespace: default
labels:
app: helloworld-deployment
spec:
replicas: 1
selector:
matchLabels:
app: helloworld-deployment
template:
metadata:
labels:
app: helloworld-deployment
spec:
containers:
- name: springapp
image: yogeshpri/devopsexam
imagePullPolicy: Always
13 changes: 13 additions & 0 deletions services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: hello-world-service
spec:
selector:
app: helloworld-deployment
ports:
- protocol: TCP
port: 80
targetPort: 8080
nodePort: 30015
type: NodePort