From e92e900a0f2dd1188806335efffd2fde12860124 Mon Sep 17 00:00:00 2001
From: rajesh <21985A0305@raghuenggcollege.in>
Date: Thu, 18 Sep 2025 06:17:54 +0530
Subject: [PATCH 1/6] Create Dockerfile
---
Dockerfile | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 Dockerfile
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..64da7550
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,14 @@
+# Use an official OpenJDK runtime as a parent image
+FROM openjdk:17-jdk-slim
+
+# Set the working directory inside the container
+WORKDIR /app
+
+# Copy the built jar file into the container
+COPY target/spring-boot-web-0.0.1-SNAPSHOT.jar app.jar
+
+# Expose the default Spring Boot port
+EXPOSE 8080
+
+# Run the jar file
+ENTRYPOINT ["java", "-jar", "app.jar"]
From 2224e9eacd65ceac29a39d016959edc855b12453 Mon Sep 17 00:00:00 2001
From: rajesh <21985A0305@raghuenggcollege.in>
Date: Wed, 24 Sep 2025 07:06:46 +0530
Subject: [PATCH 2/6] Update pom.xml
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 500bd6b8..7ea372f7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
guru.springframework
- spring-boot-web
+ spring-app
0.0.1-SNAPSHOT
jar
From d60a935dc2eeb3b11c8482f230b6e3348feeaf46 Mon Sep 17 00:00:00 2001
From: rajesh <21985A0305@raghuenggcollege.in>
Date: Wed, 24 Sep 2025 07:08:46 +0530
Subject: [PATCH 3/6] Update pom.xml
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 7ea372f7..587ed116 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
guru.springframework
spring-app
0.0.1-SNAPSHOT
- jar
+ war
Spring Boot Web Application
Spring Boot Web Application
From 2071b263a75580ff905ceca10f8111dfa2cd897c Mon Sep 17 00:00:00 2001
From: rajesh <21985A0305@raghuenggcollege.in>
Date: Wed, 24 Sep 2025 07:12:45 +0530
Subject: [PATCH 4/6] Update pom.xml
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 587ed116..ccff5ff9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
guru.springframework
spring-app
0.0.1-SNAPSHOT
- war
+ ear
Spring Boot Web Application
Spring Boot Web Application
From 79a533f1ff6d2a066a45bb22c404ae9b804f19ce Mon Sep 17 00:00:00 2001
From: rajesh <21985A0305@raghuenggcollege.in>
Date: Wed, 24 Sep 2025 07:13:54 +0530
Subject: [PATCH 5/6] Update pom.xml
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index ccff5ff9..7ea372f7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
guru.springframework
spring-app
0.0.1-SNAPSHOT
- ear
+ jar
Spring Boot Web Application
Spring Boot Web Application
From ecb8e5df5ab60a42751ff072e88260cc1c90ad21 Mon Sep 17 00:00:00 2001
From: rajesh <21985A0305@raghuenggcollege.in>
Date: Wed, 24 Sep 2025 07:21:34 +0530
Subject: [PATCH 6/6] Create Jenkinsfile
---
Jenkinsfile | 172 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 172 insertions(+)
create mode 100644 Jenkinsfile
diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 00000000..2027e0b0
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,172 @@
+pipeline {
+ agent any
+
+ environment {
+ AWS_REGION = 'eu-north-1'
+ CLUSTER_NAME = 'ekscluster'
+ ECR_REPO = 'awsdockerimages'
+ ECR_URI = "522448740060.dkr.ecr.${AWS_REGION}.amazonaws.com/${ECR_REPO}"
+ IMAGE_TAG = 'latest'
+ }
+
+ stages {
+ stage("Checkout Source Code") {
+ steps {
+ git 'https://github.com/rajesh-305/springbootwebapp.git'
+ slackSend channel: 'new-channel', message: 'Source code checked out successfully'
+ }
+ }
+ stage("Compile Source") {
+ steps {
+ sh 'mvn compile'
+ slackSend channel: 'new-channel', message: 'Compilation done successfully'
+ }
+ }
+ stage("Run Test Cases") {
+ steps {
+ sh 'mvn test'
+ slackSend channel: 'new-channel', message: 'Test cases ran successfully'
+ }
+ }
+ stage("Create Package") {
+ steps {
+ sh 'mvn package'
+ slackSend channel: 'new-channel', message: 'build artifact created successfully'
+ }
+ }
+ stage("Create ECR Repository") {
+ steps {
+ withAWS(credentials: 'aws-credentials', region: "${AWS_REGION}") {
+ script {
+ def repoExists = sh(script: "aws ecr describe-repositories --repository-names ${ECR_REPO} --region ${AWS_REGION} --query 'repositories[0].repositoryName' --output text", returnStatus: true) == 0
+ if (!repoExists) {
+ sh "aws ecr create-repository --repository-name ${ECR_REPO} --region ${AWS_REGION}"
+ echo "ECR repository ${ECR_REPO} created successfully."
+ slackSend channel: 'new-channel', message: 'ECR successful'
+ } else {
+ echo "ECR repository ${ECR_REPO} already exists."
+ slackSend channel: 'new-channel', message: 'ECR creation failed'
+ }
+ }
+ }
+ }
+ }
+ stage("Build Docker Image") {
+ steps {
+ sh "aws ecr get-login-password --region ${AWS_REGION} | docker login --username AWS --password-stdin ${ECR_URI}"
+ sh "docker build -t ${ECR_REPO} ."
+ slackSend channel: 'new-channel', message: 'Built successfully '
+ }
+ }
+ stage("Tag Docker Image") {
+ steps {
+ sh "docker tag ${ECR_REPO}:latest ${ECR_URI}:${IMAGE_TAG}"
+ slackSend channel: 'new-channel', message: 'Success!'
+ }
+ }
+ stage("Push Docker Image to ECR") {
+ steps {
+ sh "docker push ${ECR_URI}:${IMAGE_TAG}"
+ slackSend channel: 'new-channel', message: 'Success!'
+ }
+ }
+ stage("Setup AWS Credentials") {
+ steps {
+ withCredentials([[
+ $class: 'AmazonWebServicesCredentialsBinding',
+ credentialsId: 'aws-credentials',
+ accessKeyVariable: 'AWS_ACCESS_KEY_ID',
+ secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
+ ]]) {
+ sh 'export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID'
+ sh 'export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY'
+ sh 'aws sts get-caller-identity'
+ }
+ }
+ }
+ /*
+ stage("Create EKS Cluster") {
+ steps {
+ sh """
+ eksctl create cluster \\
+ --name ${CLUSTER_NAME} \\
+ --region ${AWS_REGION} \\
+ --nodes 3 \\
+ --node-type t3.medium
+ """
+ }
+ }
+ stage("Update Kubeconfig") {
+ steps {
+ sh "aws eks update-kubeconfig --name ${CLUSTER_NAME} --region ${AWS_REGION}"
+ sh "kubectl get nodes"
+ }
+ } */
+ stage("Continuous_Delivery")
+ {
+ steps
+ {
+ slackSend channel: 'new-channel', message: 'Waiting for approval from Shekar'
+ input message: 'Waiting for approval from Shekar', submitter: 'shekar'
+
+ }
+ }
+ stage("Deploy Pod to EKS") {
+ steps {
+ script {
+ def podManifest = """
+apiVersion: v1
+kind: Pod
+metadata:
+ name: springbootwebapp
+spec:
+ containers:
+ - name: springbootwebapp
+ image: ${ECR_URI}:${IMAGE_TAG}
+ ports:
+ - containerPort: 8080
+"""
+ writeFile file: 'pod.yaml', text: podManifest
+ sh "kubectl apply -f pod.yaml"
+ sh "kubectl get pods"
+ }
+ }
+ }
+ stage("Expose Pod via NodePort Service") {
+ steps {
+ script {
+ def serviceManifest = """
+apiVersion: v1
+kind: Service
+metadata:
+ name: springbootwebapp-service
+spec:
+ type: NodePort
+ selector:
+ name: springbootwebapp
+ ports:
+ - protocol: TCP
+ port: 8080
+ targetPort: 8080
+ nodePort: 30080
+"""
+ // Patch pod label for selector
+ sh "kubectl label pod springbootwebapp name=springbootwebapp --overwrite"
+ writeFile file: 'service.yaml', text: serviceManifest
+ sh "kubectl apply -f service.yaml"
+ sh "kubectl get svc"
+ }
+ }
+ }
+
+ }
+ post {
+ success {
+slackSend channel: 'new-channel', message: 'The pipeline executed successfully'
+
+ }
+ failure {
+ slackSend channel: 'new-channel', message: 'Pipeline Failed'
+ }
+ }
+}