From 5ef7ca7211ad9458925459258e2d397bafca6c99 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 15 Oct 2024 10:06:06 +0530 Subject: [PATCH 1/9] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ae4ea5..2e5dabb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Sysfoo Application -A Devops Learning App +A Devops Learning App test ## About the Application From 04410698bed39c28e4c390e18a503170374665d1 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 15 Oct 2024 11:16:53 +0530 Subject: [PATCH 2/9] Create Jenkinsfile --- Jenkinsfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..0891802 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,27 @@ +pipeline{ + agent any + + tools { + maven 'Maven 3.6.3' + } + stages{ + stage('build'){ + steps{ + echo 'compile maven app' + sh 'mvn compile' + } + } + stage('test'){ + steps{ + echo 'test maven app' + sh 'mvn clean test' + } + } + stage('package'){ + steps{ + echo 'package maven app' + sh 'mvn package -DskipTests' + } + } + } +} From 65633808dc7e72acfd9a2b5c23be8950e21b98c1 Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 15 Oct 2024 11:23:29 +0530 Subject: [PATCH 3/9] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0891802..a5e9d83 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline{ agent any tools { - maven 'Maven 3.6.3' + maven '3.6.3' } stages{ stage('build'){ From 462e62e009669c70478082d68b1d5a2a61b1b2bd Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 15 Oct 2024 11:27:57 +0530 Subject: [PATCH 4/9] adding artifect archival step --- Jenkinsfile | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a5e9d83..79b368b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,27 +1,30 @@ -pipeline{ +pipeline { agent any - - tools { - maven '3.6.3' - } - stages{ - stage('build'){ - steps{ + stages { + stage('build') { + steps { echo 'compile maven app' sh 'mvn compile' } } - stage('test'){ - steps{ + + stage('test') { + steps { echo 'test maven app' sh 'mvn clean test' } } - stage('package'){ - steps{ + + stage('package') { + steps { echo 'package maven app' sh 'mvn package -DskipTests' + archiveArtifacts 'target/*.jar' } } + + } + tools { + maven '3.6.3' } -} +} \ No newline at end of file From cdac4eb14d296d22bd4252b8c34bf5e3ece2ad04 Mon Sep 17 00:00:00 2001 From: Rajnish Kumar Robin Date: Wed, 16 Oct 2024 09:46:09 +0530 Subject: [PATCH 5/9] adding some lines --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2e5dabb..6b0f158 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # Sysfoo Application A Devops Learning App test - +adding someting to raise PR ## About the Application The Sysfoo application is designed as a learning tool to demonstrate various aspects of web development using Spring Boot and other associated technologies. It provides real-time system information, database connectivity status, and a basic to-do list functionality to illustrate interaction with a database. From d629b914b40a5c255645adf4f2f6b0678445cdc8 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 16 Oct 2024 10:35:58 +0530 Subject: [PATCH 6/9] adding an agent --- Jenkinsfile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 79b368b..a82e9b5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,10 @@ pipeline { - agent any + agent { + docker { + image 'maven:3.9.6-eclipse-temurin-17' + } + + } stages { stage('build') { steps { From 02bad145b3686fdbbda8507ac18c59e659cadaf6 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 16 Oct 2024 10:41:34 +0530 Subject: [PATCH 7/9] stage agents --- Jenkinsfile | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a82e9b5..5f7908d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,12 +1,13 @@ pipeline { - agent { - docker { - image 'maven:3.9.6-eclipse-temurin-17' - } - - } + agent none stages { stage('build') { + agent { + docker { + image 'maven:3.9.6-eclipse-temurin-17' + } + + } steps { echo 'compile maven app' sh 'mvn compile' @@ -14,6 +15,12 @@ pipeline { } stage('test') { + agent { + docker { + image 'maven:3.9.6-eclipse-temurin-17' + } + + } steps { echo 'test maven app' sh 'mvn clean test' @@ -21,6 +28,12 @@ pipeline { } stage('package') { + agent { + docker { + image 'maven:3.9.6-eclipse-temurin-17' + } + + } steps { echo 'package maven app' sh 'mvn package -DskipTests' From c48294d4cbe1ae082dfbf59f50dc437de27d4a89 Mon Sep 17 00:00:00 2001 From: Rajnish Kumar Robin Date: Wed, 16 Oct 2024 15:20:18 +0530 Subject: [PATCH 8/9] adding a docker file --- Dockerfile | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d0a0f7a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM maven:3.9.6-eclipse-temurin-17 AS build + +WORKDIR /app +COPY . . +RUN mvn package -DskipTest + +FROM eclipse-temurin:17-jre-noble as package +WORKDIR /app +COPY --from=build /app/target/sysfoo-*.jar ./sysfoo.jar +EXPOSE 8080 +ENTRYPOINT ["java", "-jar", "sysfoo.jar"] From 2ffccd1eea72fb8c8e7adcad41cbcb69109aba55 Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 16 Oct 2024 15:22:42 +0530 Subject: [PATCH 9/9] docker build step addition --- Jenkinsfile | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5f7908d..b9f2397 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -28,16 +28,31 @@ pipeline { } stage('package') { - agent { - docker { - image 'maven:3.9.6-eclipse-temurin-17' + parallel { + stage('package') { + agent { + docker { + image 'maven:3.9.6-eclipse-temurin-17' + } + + } + steps { + echo 'package maven app' + sh 'mvn package -DskipTests' + archiveArtifacts 'target/*.jar' + } + } + + stage('DOCKER BUILD') { + steps { + script { + def commitHash = env.GIT_COMMIT.take(7) + def dockerImage = docker.build("xxxxxx/sysfoo:${commitHash}", "./") + } + + } } - } - steps { - echo 'package maven app' - sh 'mvn package -DskipTests' - archiveArtifacts 'target/*.jar' } }