From ef56a8a68af0aa9b2b4b4c3201d45b2b35c5f717 Mon Sep 17 00:00:00 2001 From: aruizcanton Date: Wed, 19 Apr 2023 08:11:49 +0000 Subject: [PATCH 01/12] He cambiado readme.md para hacer una prueba --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index b8ad8a94..2c6b90b5 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ Once you have your swarm, in this directory run: ``` docker stack deploy --compose-file docker-stack.yml vote ``` - Run the app in Kubernetes ------------------------- From 87fe71331ebdeb6808408a59fdd3db315b7eedf7 Mon Sep 17 00:00:00 2001 From: aruizcanton Date: Mon, 24 Apr 2023 09:08:27 +0000 Subject: [PATCH 02/12] test --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2c6b90b5..44aa69ee 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ Once you have your swarm, in this directory run: ``` docker stack deploy --compose-file docker-stack.yml vote ``` +Esto es una prueba + Run the app in Kubernetes ------------------------- From 55e67b76f61f88a966e7847d93602be46942d9ca Mon Sep 17 00:00:00 2001 From: aruizcanton Date: Mon, 24 Apr 2023 09:32:28 +0000 Subject: [PATCH 03/12] added application info --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 44aa69ee..a18b7dcc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ Example Voting App ========= +THIS IS A SAMPLE VOTING APP. + Getting started --------------- From dde1ae6d7947f33c5c7ceac9920a1afab35c0b8f Mon Sep 17 00:00:00 2001 From: aruizcanton Date: Fri, 28 Apr 2023 07:43:26 +0000 Subject: [PATCH 04/12] added Jenkinsfile for worker with build job --- worker/Jenkinsfile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 worker/Jenkinsfile diff --git a/worker/Jenkinsfile b/worker/Jenkinsfile new file mode 100644 index 00000000..7949d230 --- /dev/null +++ b/worker/Jenkinsfile @@ -0,0 +1,31 @@ +pipeline { + agent any + tools { + maven 'maven 3.6.1' + } + stages { + stage ("build") { + steps { + echo 'Compiling working app' + dir ('worker') { + sh 'mvn compile' + } + } + } + stage ("test") { + steps { + echo 'Running Unit Test on worker app' + } + } + stage ("package") { + steps { + echo 'Packaging working app' + } + } + } + post { + always { + echo 'Building multibranch pipeline for worker is completed..' + } + } +} From 63b35e60c281bf5c7cb8747069c411e999747e65 Mon Sep 17 00:00:00 2001 From: aruizcanton Date: Fri, 28 Apr 2023 09:52:02 +0000 Subject: [PATCH 05/12] added Test and package job for worker pipeline --- worker/Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/worker/Jenkinsfile b/worker/Jenkinsfile index 7949d230..61f45202 100644 --- a/worker/Jenkinsfile +++ b/worker/Jenkinsfile @@ -15,11 +15,17 @@ pipeline { stage ("test") { steps { echo 'Running Unit Test on worker app' + dir ('worker') { + sh 'mvn clean test' + } } } stage ("package") { steps { echo 'Packaging working app' + dir ('worker') { + sh 'mvn package' + } } } } From 8a911443fa22205911b650bcd5fefe28161d341a Mon Sep 17 00:00:00 2001 From: aruizcanton Date: Fri, 28 Apr 2023 10:48:16 +0000 Subject: [PATCH 06/12] run package step only on master , run stages only when worker changes --- worker/Jenkinsfile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/worker/Jenkinsfile b/worker/Jenkinsfile index 61f45202..76dfeab4 100644 --- a/worker/Jenkinsfile +++ b/worker/Jenkinsfile @@ -5,6 +5,9 @@ pipeline { } stages { stage ("build") { + when { + changeset "**/worker/**" + } steps { echo 'Compiling working app' dir ('worker') { @@ -13,6 +16,9 @@ pipeline { } } stage ("test") { + when { + changeset "**/worker/**" + } steps { echo 'Running Unit Test on worker app' dir ('worker') { @@ -21,10 +27,15 @@ pipeline { } } stage ("package") { + when { + branch 'master' + changeset "**/worker/**" steps { echo 'Packaging working app' dir ('worker') { - sh 'mvn package' + sh 'mvn package -DskipTests' + archiveArtifacts artifacts: '**/target/*.jar', + fingerprint: true } } } From b46a5793bb2355bd5709eb165b8c4ee528476546 Mon Sep 17 00:00:00 2001 From: aruizcanton Date: Fri, 12 May 2023 07:35:43 +0000 Subject: [PATCH 07/12] adding Jenkinsfile for result app --- result/Jenkinsfile | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 result/Jenkinsfile diff --git a/result/Jenkinsfile b/result/Jenkinsfile new file mode 100644 index 00000000..f9781b99 --- /dev/null +++ b/result/Jenkinsfile @@ -0,0 +1,36 @@ +pipeline { + agent any + tools { + nodejs 'NodeJS 8.9.0' + } + stages { + stage ("build") { + when { + changeset "**/result/**" + } + steps { + echo 'Compiling result app' + dir ('worker') { + sh 'npm install' + } + } + } + stage ("test") { + when { + changeset "**/result/**" + } + steps { + echo 'Running Unit Test on result app' + dir ('result') { + sh 'npm install' + sh 'npm test' + } + } + } + } + post { + always { + echo 'Building multibranch pipeline for result is completed..' + } + } +} From d1ae09c635b048575226c0980b7723ef5e4444b2 Mon Sep 17 00:00:00 2001 From: aruizcanton Date: Fri, 12 May 2023 08:02:04 +0000 Subject: [PATCH 08/12] adding mock test --- result/test/mock.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/result/test/mock.test.js b/result/test/mock.test.js index f99dfdae..793ee9f3 100644 --- a/result/test/mock.test.js +++ b/result/test/mock.test.js @@ -26,4 +26,9 @@ describe('mock test 4', () => { }); }); +describe('mock test 5', () => { + it('unit test 5', () => { + expect(true).to.be.true; + }); +}); From 8565bc32cb821580720b192efc44d88def86923d Mon Sep 17 00:00:00 2001 From: Angel Ruiz Canton Date: Fri, 12 Jan 2024 10:31:46 +0100 Subject: [PATCH 09/12] add docker based agent --- worker/Jenkinsfile | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/worker/Jenkinsfile b/worker/Jenkinsfile index 76dfeab4..710d7355 100644 --- a/worker/Jenkinsfile +++ b/worker/Jenkinsfile @@ -1,8 +1,10 @@ pipeline { - agent any - tools { - maven 'maven 3.6.1' - } + agent{ + docker{ + image 'maven:3.6.1-jdk-8-slim' + args '-v $HOME/.m2:/root/.m2' + } + } stages { stage ("build") { when { @@ -30,19 +32,20 @@ pipeline { when { branch 'master' changeset "**/worker/**" - steps { - echo 'Packaging working app' - dir ('worker') { - sh 'mvn package -DskipTests' - archiveArtifacts artifacts: '**/target/*.jar', - fingerprint: true + steps { + echo 'Packaging working app' + dir ('worker') { + sh 'mvn package -DskipTests' + archiveArtifacts artifacts: '**/target/*.jar', + fingerprint: true + } } } } - } - post { - always { - echo 'Building multibranch pipeline for worker is completed..' + post { + always { + echo 'Building multibranch pipeline for worker is completed..' + } } } } From 99b0432891d4efb5dc237550ae15b3750435d298 Mon Sep 17 00:00:00 2001 From: Angel Ruiz Canton Date: Thu, 25 Jan 2024 09:54:27 +0100 Subject: [PATCH 10/12] adding Dockerfile for worker --- worker/Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 worker/Dockerfile diff --git a/worker/Dockerfile b/worker/Dockerfile new file mode 100644 index 00000000..12bf7731 --- /dev/null +++ b/worker/Dockerfile @@ -0,0 +1,5 @@ +FROM maven:3.6.1-jdk-8-slim +WORKDIR /app +COPY . . +RUN mvn package && mv target/worker-jar-with-dependencies.jar /run/worker.jar && rm -rf /app/* +CMD java -jar /run/worker.jar \ No newline at end of file From cd901bb8a1e5bbf21dd590e82295f1dbfa22f341 Mon Sep 17 00:00:00 2001 From: Angel Ruiz Canton Date: Fri, 26 Jan 2024 10:00:59 +0100 Subject: [PATCH 11/12] per stage agents, conditional execution --- worker/Jenkinsfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/worker/Jenkinsfile b/worker/Jenkinsfile index 710d7355..d1f44853 100644 --- a/worker/Jenkinsfile +++ b/worker/Jenkinsfile @@ -42,6 +42,19 @@ pipeline { } } } + stage ('docker-package') { + agent any + steps { + echo 'Packaging worker app with docker' + script { + docker.withRegistry('https://index.docker.io/v1/','dockerlogin') { + def workerImage = docker.build("aruizcanton/worker:v${env.BUILD_ID}", "./ worker") + workerImage.push() + workerImage.push("latest") + } + } + } + } post { always { echo 'Building multibranch pipeline for worker is completed..' From d35a374efcffadb66c0da2f3493b52f33710a092 Mon Sep 17 00:00:00 2001 From: Angel Ruiz Canton Date: Fri, 26 Jan 2024 11:54:23 +0100 Subject: [PATCH 12/12] per stage agents, conditional execution --- worker/Jenkinsfile | 49 +++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/worker/Jenkinsfile b/worker/Jenkinsfile index d1f44853..8986ade0 100644 --- a/worker/Jenkinsfile +++ b/worker/Jenkinsfile @@ -1,17 +1,18 @@ pipeline { - agent{ - docker{ - image 'maven:3.6.1-jdk-8-slim' - args '-v $HOME/.m2:/root/.m2' - } - } + agent none stages { stage ("build") { when { changeset "**/worker/**" } + agent { + docker { + image 'maven:3.6.1-jdk-8-slim' + args '-v $HOME/.m2:/root/.m2' + } + } steps { - echo 'Compiling working app' + echo 'Compiling working app...' dir ('worker') { sh 'mvn compile' } @@ -21,6 +22,12 @@ pipeline { when { changeset "**/worker/**" } + agent { + docker { + image 'maven:3.6.1-jdk-8-slim' + args '-v $HOME/.m2:/root/.m2' + } + } steps { echo 'Running Unit Test on worker app' dir ('worker') { @@ -32,22 +39,32 @@ pipeline { when { branch 'master' changeset "**/worker/**" - steps { - echo 'Packaging working app' - dir ('worker') { - sh 'mvn package -DskipTests' - archiveArtifacts artifacts: '**/target/*.jar', - fingerprint: true - } + } + agent { + docker { + image 'maven:3.6.1-jdk-8-slim' + args '-v $HOME/.m2:/root/.m2' + } + } + steps { + echo 'Packaging working app' + dir ('worker') { + sh 'mvn package -DskipTests' + archiveArtifacts artifacts: '**/target/*.jar', + fingerprint: true } } } stage ('docker-package') { agent any + when { + changeset "**/worker/**" + branch 'master + } steps { echo 'Packaging worker app with docker' script { - docker.withRegistry('https://index.docker.io/v1/','dockerlogin') { + docker.withRegistry ('https://index.docker.io/v1/','dockerlogin') { def workerImage = docker.build("aruizcanton/worker:v${env.BUILD_ID}", "./ worker") workerImage.push() workerImage.push("latest") @@ -57,7 +74,7 @@ pipeline { } post { always { - echo 'Building multibranch pipeline for worker is completed..' + echo 'Building multibranch pipeline for worker is completed...' } } }