From 04fef5a48f58737a613755c9f011925df04e4983 Mon Sep 17 00:00:00 2001 From: Daniel Robles Date: Mon, 7 Nov 2022 19:31:46 -0300 Subject: [PATCH 01/92] se agrega jenkins file --- Jenkinsfile | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..d3981e68 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,47 @@ +import groovy.json.JsonSlurperClassic +def jsonParse(def json) { + new groovy.json.JsonSlurperClassic().parseText(json) +} +pipeline { + agent any + stages { + stage("Paso 1: Compilar"){ + steps { + script { + sh "echo 'Compile Code!'" + // Run Maven on a Unix agent. + sh "./mvnw clean compile -e" + } + } + } + stage("Paso 2: Testear"){ + steps { + script { + sh "echo 'Test Code!'" + // Run Maven on a Unix agent. + sh "./mvnw clean test -e" + } + } + } + stage("Paso 3: Build .Jar"){ + steps { + script { + sh "echo 'Build .Jar!'" + // Run Maven on a Unix agent. + sh "./mvnw clean package -e" + } + } + } + } + post { + always { + sh "echo 'fase always executed post'" + } + success { + sh "echo 'fase success'" + } + failure { + sh "echo 'fase failure'" + } + } +} \ No newline at end of file From 98a2e125f28ca14badce6326647c77f695c1e53b Mon Sep 17 00:00:00 2001 From: Daniel Robles Date: Mon, 7 Nov 2022 19:56:16 -0300 Subject: [PATCH 02/92] prueba de jenkins --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b67037b..a5e2a553 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Getting Started - +tst ## Windows ### Compile Code From c191bcd20d310c1243bbd9950b46b48a3df22985 Mon Sep 17 00:00:00 2001 From: krostyle Date: Mon, 7 Nov 2022 20:19:46 -0300 Subject: [PATCH 03/92] add member --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 9b67037b..606296f4 100644 --- a/README.md +++ b/README.md @@ -44,3 +44,7 @@ - Agregar archivo **_Jenkinsfile_** en la raíz de la rama del proyecto a procesar (sólo como pivote al código del pipeline). - Registrar Pipeline en **_Jenkins -> Administrar Jenkins -> Configuración Global -> Global Pipeline Libraries_** bajo el nombre **_pipeline_** - Configurar _Multibranch Pipeline Job_ o _Pipeline Job_ en Jenkins con el repositorio del proyecto a procesar. + + +# Integrantes +- Diego Bustamante \ No newline at end of file From 99e4d4d098405ab11a038871ba1cdc60bf2dddbc Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Tue, 8 Nov 2022 22:34:01 -0300 Subject: [PATCH 04/92] Update Jenkinsfile --- Jenkinsfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d3981e68..9b60ce4d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,6 +32,14 @@ pipeline { } } } + stage("Paso 4: Build .Jar"){ + steps { + script { + sh 'sleep 3000' + curl -X GET 'http://localhost:8080/rest/mscovid/test?msg=testing' + } + } + } } post { always { @@ -44,4 +52,4 @@ pipeline { sh "echo 'fase failure'" } } -} \ No newline at end of file +} From 354b77a44e8241f5144e0fcbaa919efe8b2a84fb Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Tue, 8 Nov 2022 22:35:46 -0300 Subject: [PATCH 05/92] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 270ee580..42c9df86 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Getting Started -tst + ## Windows ### Compile Code @@ -47,4 +47,4 @@ tst # Integrantes -- Diego Bustamante \ No newline at end of file +- Diego Bustamante From 3045c1959a29e9c3ac70a7d7927a844b29b38716 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Tue, 8 Nov 2022 22:37:35 -0300 Subject: [PATCH 06/92] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9b60ce4d..3eca7c3b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,8 +35,8 @@ pipeline { stage("Paso 4: Build .Jar"){ steps { script { - sh 'sleep 3000' - curl -X GET 'http://localhost:8080/rest/mscovid/test?msg=testing' + sh "sleep 10" + sh "curl -X GET 'http://localhost:8080/rest/mscovid/test?msg=testing'" } } } From 3d79f5c27f000894004103a7848b6593bc882a6f Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Tue, 8 Nov 2022 22:39:16 -0300 Subject: [PATCH 07/92] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 42c9df86..0926f598 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Getting Started ## Windows - +aaa ### Compile Code * ./mvnw.cmd clean compile -e From 5a5cdd8d6a1fd78d4a4bdd366e0cbd771158d033 Mon Sep 17 00:00:00 2001 From: Daniel Robles Date: Tue, 8 Nov 2022 22:40:29 -0300 Subject: [PATCH 08/92] test jenkins --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0926f598..2c1524a3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Getting Started ## Windows -aaa +aaaa ### Compile Code * ./mvnw.cmd clean compile -e From 068def0ef13dafaabb72f270ea6cd19b96761523 Mon Sep 17 00:00:00 2001 From: Daniel Robles Date: Tue, 8 Nov 2022 22:43:56 -0300 Subject: [PATCH 09/92] test jenkins pipeline --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3eca7c3b..6cf37ce9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,7 +36,7 @@ pipeline { steps { script { sh "sleep 10" - sh "curl -X GET 'http://localhost:8080/rest/mscovid/test?msg=testing'" + sh "curl -X GET 'http://localhost:8081/rest/mscovid/test?msg=testing'" } } } From 6ad88a690e06ad84de0c2c1f1de351446389231f Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Tue, 8 Nov 2022 22:45:01 -0300 Subject: [PATCH 10/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6cf37ce9..506c1a1a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,7 +35,7 @@ pipeline { stage("Paso 4: Build .Jar"){ steps { script { - sh "sleep 10" + sh "sleep 120" sh "curl -X GET 'http://localhost:8081/rest/mscovid/test?msg=testing'" } } From 0c96480f92bd42591a784b25c6202f13c3bc48f1 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Tue, 8 Nov 2022 22:54:09 -0300 Subject: [PATCH 11/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 506c1a1a..e674cf40 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,7 +35,7 @@ pipeline { stage("Paso 4: Build .Jar"){ steps { script { - sh "sleep 120" + sh "sleep 300" sh "curl -X GET 'http://localhost:8081/rest/mscovid/test?msg=testing'" } } From 8a4a70fca2c67ca23b6c917df8971146329725ab Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Tue, 8 Nov 2022 22:58:19 -0300 Subject: [PATCH 12/92] Update Jenkinsfile --- Jenkinsfile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e674cf40..ca727052 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,10 +32,18 @@ pipeline { } } } - stage("Paso 4: Build .Jar"){ + stage("Paso 4: Run .Jar"){ steps { script { - sh "sleep 300" + sh "echo 'Running .Jar file!'" + sh "./mvnw spring-boot:run &" + } + } + } + stage("Paso 5: Build .Jar"){ + steps { + script { + sh "sleep 120" sh "curl -X GET 'http://localhost:8081/rest/mscovid/test?msg=testing'" } } From fbaeb3e4ed6827e2f36ec212ab9afefd8e81a3c3 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Tue, 8 Nov 2022 23:03:59 -0300 Subject: [PATCH 13/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ca727052..b5b5a35c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -43,7 +43,7 @@ pipeline { stage("Paso 5: Build .Jar"){ steps { script { - sh "sleep 120" + sh "sleep 30" sh "curl -X GET 'http://localhost:8081/rest/mscovid/test?msg=testing'" } } From 45ec360523dc99e620258da944c0027270833d01 Mon Sep 17 00:00:00 2001 From: Yrma Ccencho Date: Tue, 8 Nov 2022 23:14:42 -0300 Subject: [PATCH 14/92] estado-pais --- Jenkinsfile | 2 +- .../com/devopsusach2020/rest/RestData.java | 27 +++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b5b5a35c..fa56d30d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -44,7 +44,7 @@ pipeline { steps { script { sh "sleep 30" - sh "curl -X GET 'http://localhost:8081/rest/mscovid/test?msg=testing'" + sh "curl -X GET 'http://localhost:8081/rest/mscovid/estadoPais?pais=Chile'" } } } diff --git a/src/main/java/com/devopsusach2020/rest/RestData.java b/src/main/java/com/devopsusach2020/rest/RestData.java index e06ca00f..4c896b08 100644 --- a/src/main/java/com/devopsusach2020/rest/RestData.java +++ b/src/main/java/com/devopsusach2020/rest/RestData.java @@ -23,13 +23,30 @@ public class RestData { private final static Logger LOGGER = Logger.getLogger("devops.subnivel.Control"); - @GetMapping(path = "/test", produces = MediaType.APPLICATION_JSON_VALUE) - public @ResponseBody Pais getData(@RequestParam(name = "msg") String message){ - - LOGGER.log(Level.INFO, "Proceso exitoso de prueba"); + @GetMapping(path = "/estadoPais", produces = MediaType.APPLICATION_JSON_VALUE) + public @ResponseBody Pais getTotalPais(@RequestParam(name = "pais") String message){ + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity call = restTemplate.getForEntity("https://api.covid19api.com/live/country/" + message, String.class); + LOGGER.log(Level.INFO, "Consulta por pais "); Pais response = new Pais(); - response.setMensaje("Mensaje Recibido: " + message); + int confirmed = 0; + int death = 0; + int recovered = 0; + Gson gson = new Gson(); + Pais[] estados = gson.fromJson(call.getBody().toLowerCase(), Pais[].class); + for(Pais estado : estados){ + response.setDate(estado.getDate()); + response.setActive(estado.getActive()); + confirmed += estado.getConfirmed(); + death += estado.getDeaths(); + recovered += estado.getRecovered(); + } + response.setConfirmed(confirmed); + response.setDeaths(death); + response.setRecovered(recovered); + response.setCountry(message); + response.setMensaje("ok"); return response; } } From 8fc394946f1ec491004e226b726b19776ad647d1 Mon Sep 17 00:00:00 2001 From: Daniel Morales Date: Tue, 8 Nov 2022 23:23:58 -0300 Subject: [PATCH 15/92] Sube feature estado-mundial --- .../java/com/devopsusach2020/rest/RestData.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/devopsusach2020/rest/RestData.java b/src/main/java/com/devopsusach2020/rest/RestData.java index e06ca00f..fa454d11 100644 --- a/src/main/java/com/devopsusach2020/rest/RestData.java +++ b/src/main/java/com/devopsusach2020/rest/RestData.java @@ -33,3 +33,18 @@ public class RestData { return response; } } + +@GetMapping(path = "/estadoMundial", produces = MediaType.APPLICATION_JSON_VALUE) + public @ResponseBody Mundial getTotalMundial(){ + + LOGGER.log(Level.INFO, "Consulta mundial"); + RestTemplate restTemplate = new RestTemplate(); + ResponseEntity call = restTemplate.getForEntity("https://api.covid19api.com/world/total", String.class); + Mundial response = new Mundial(); + Gson gson = new Gson(); + Mundial estado = gson.fromJson(call.getBody().toLowerCase(), Mundial.class); + response.setTotalConfirmed(estado.getTotalConfirmed()); + response.setTotalDeaths(estado.getTotalDeaths()); + response.setTotalRecovered(estado.getTotalRecovered()); + return response; + } \ No newline at end of file From 0a7fbb2646aa32f04532584857ad1bb3c5086d31 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Tue, 8 Nov 2022 23:35:59 -0300 Subject: [PATCH 16/92] Update RestData.java correccion tipeo string --- src/main/java/com/devopsusach2020/rest/RestData.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/devopsusach2020/rest/RestData.java b/src/main/java/com/devopsusach2020/rest/RestData.java index 4c896b08..f3fdb720 100644 --- a/src/main/java/com/devopsusach2020/rest/RestData.java +++ b/src/main/java/com/devopsusach2020/rest/RestData.java @@ -26,7 +26,7 @@ public class RestData { @GetMapping(path = "/estadoPais", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Pais getTotalPais(@RequestParam(name = "pais") String message){ RestTemplate restTemplate = new RestTemplate(); - ResponseEntity call = restTemplate.getForEntity("https://api.covid19api.com/live/country/" + message, String.class); + ResponseEntity call = restTemplate.getForEntity("https://api.covid19api.com/live/country/" + message, String.class); LOGGER.log(Level.INFO, "Consulta por pais "); Pais response = new Pais(); From 1a7c5b6ecdbf31e79a1e2c068163381b1b0ac466 Mon Sep 17 00:00:00 2001 From: Daniel Morales Date: Tue, 8 Nov 2022 23:40:54 -0300 Subject: [PATCH 17/92] Agrega codigo con error --- src/main/java/com/devopsusach2020/rest/RestData.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/devopsusach2020/rest/RestData.java b/src/main/java/com/devopsusach2020/rest/RestData.java index fa454d11..33442d91 100644 --- a/src/main/java/com/devopsusach2020/rest/RestData.java +++ b/src/main/java/com/devopsusach2020/rest/RestData.java @@ -32,7 +32,6 @@ public class RestData { response.setMensaje("Mensaje Recibido: " + message); return response; } -} @GetMapping(path = "/estadoMundial", produces = MediaType.APPLICATION_JSON_VALUE) public @ResponseBody Mundial getTotalMundial(){ @@ -47,4 +46,5 @@ public class RestData { response.setTotalDeaths(estado.getTotalDeaths()); response.setTotalRecovered(estado.getTotalRecovered()); return response; - } \ No newline at end of file + } +} \ No newline at end of file From c5f0f67433e03c135f1972543073329e9db4eeab Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 10:37:37 -0300 Subject: [PATCH 18/92] Create maven-publish.yml --- .github/workflows/maven-publish.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/maven-publish.yml diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml new file mode 100644 index 00000000..d5931b9c --- /dev/null +++ b/.github/workflows/maven-publish.yml @@ -0,0 +1,21 @@ +name: Java CI G7 + +on: + push: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'temurin' + cache: maven + - name: Deploy + run: mvn -B package --file pom.xml From ca29d159de31c522dddda82c3d2885c82d5dc7e2 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 13:05:10 -0300 Subject: [PATCH 19/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index d5931b9c..ec22459b 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -19,3 +19,14 @@ jobs: cache: maven - name: Deploy run: mvn -B package --file pom.xml + - name: Upload application + uses: appleboy/scp-action@master + with: + host: drobles.cl + username: ec2-user + password: grupo7 + port: 22 + source: "/home/runner/work/ms-iclab/ms-iclab/target/*.jar" + target: "/home/ec2-user/" + - name: test2 + run: echo end From cdd34b005d37c4c03dfb5fc5f4020213233d22db Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 17:14:09 -0300 Subject: [PATCH 20/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index ec22459b..d7ce598b 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -26,7 +26,7 @@ jobs: username: ec2-user password: grupo7 port: 22 - source: "/home/runner/work/ms-iclab/ms-iclab/target/*.jar" + source: "/home/runner/work/ms-iclab/ms-iclab/target/DevOpsUsach2020-2.3.4.RELEASE.jar" target: "/home/ec2-user/" - name: test2 run: echo end From 49403938ff7b46da0a94abb214aacb047e1f03aa Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 17:15:09 -0300 Subject: [PATCH 21/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index d7ce598b..0ceb9605 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -26,7 +26,7 @@ jobs: username: ec2-user password: grupo7 port: 22 - source: "/home/runner/work/ms-iclab/ms-iclab/target/DevOpsUsach2020-2.3.4.RELEASE.jar" + source: "/home/runner/work/ms-iclab/ms-iclab/build/DevOpsUsach2020-0.0.1.jar" target: "/home/ec2-user/" - name: test2 run: echo end From db28a7c70562529ad4bf3f6db23a5aedb4161f5c Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 17:36:09 -0300 Subject: [PATCH 22/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 0ceb9605..66a04e95 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -30,3 +30,17 @@ jobs: target: "/home/ec2-user/" - name: test2 run: echo end + - name: Start Service DevOpsUsach2020 + uses: appleboy/ssh-action@master + with: + host: drobles.cl + username: ec2-user + password: grupo7 + port: 22 + script: | + sudo /etc/init.d/devops stop || true + mv /home/ec2-user/devops.jar /home/ec2-user/devops-old.jar || true + mv /home/runner/work/ms-iclab/ms-iclab/build/DevOpsUsach2020-0.0.1.jar /home/ec2-user/devops.jar + sudo rm -rf /etc/init.d/devops || true + sudo ln -s /home/ec2-user/devops.jar /etc/init.d/devops + /etc/init.d/devops start From 5e4fccc9e09781f5be7c2649746ed941bc0f1057 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 17:44:17 -0300 Subject: [PATCH 23/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 66a04e95..28076133 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -40,7 +40,7 @@ jobs: script: | sudo /etc/init.d/devops stop || true mv /home/ec2-user/devops.jar /home/ec2-user/devops-old.jar || true - mv /home/runner/work/ms-iclab/ms-iclab/build/DevOpsUsach2020-0.0.1.jar /home/ec2-user/devops.jar + mv /home/ec2-user/github/workspace/build/DevOpsUsach2020-0.0.1.jar /home/ec2-user/devops.jar sudo rm -rf /etc/init.d/devops || true sudo ln -s /home/ec2-user/devops.jar /etc/init.d/devops /etc/init.d/devops start From b864c7e2dc05f61afaf735743b9615a323b1338c Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 17:50:17 -0300 Subject: [PATCH 24/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 28076133..f7677d23 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -41,6 +41,5 @@ jobs: sudo /etc/init.d/devops stop || true mv /home/ec2-user/devops.jar /home/ec2-user/devops-old.jar || true mv /home/ec2-user/github/workspace/build/DevOpsUsach2020-0.0.1.jar /home/ec2-user/devops.jar - sudo rm -rf /etc/init.d/devops || true - sudo ln -s /home/ec2-user/devops.jar /etc/init.d/devops - /etc/init.d/devops start + killall java + java -jar /home/ec2-user/devops.jar & From 3d9dd33ab00645e9768f842c311a9445e6f95ec9 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 19:12:33 -0300 Subject: [PATCH 25/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index f7677d23..3d217ab6 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -42,4 +42,4 @@ jobs: mv /home/ec2-user/devops.jar /home/ec2-user/devops-old.jar || true mv /home/ec2-user/github/workspace/build/DevOpsUsach2020-0.0.1.jar /home/ec2-user/devops.jar killall java - java -jar /home/ec2-user/devops.jar & + java -jar /home/ec2-user/devops.jar >> /dev/null & From 243463fa50c2721fa33282301292caec136d428a Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 19:20:17 -0300 Subject: [PATCH 26/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 3d217ab6..ac5066f1 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -43,3 +43,5 @@ jobs: mv /home/ec2-user/github/workspace/build/DevOpsUsach2020-0.0.1.jar /home/ec2-user/devops.jar killall java java -jar /home/ec2-user/devops.jar >> /dev/null & + sleep(10) + curl -X GET 'http://grupo7.drobles.cl/rest/mscovid/test?msg=testing' From 80862695ea562398290655f96fbfb0286b414200 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 19:23:56 -0300 Subject: [PATCH 27/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index ac5066f1..8432be39 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -43,5 +43,11 @@ jobs: mv /home/ec2-user/github/workspace/build/DevOpsUsach2020-0.0.1.jar /home/ec2-user/devops.jar killall java java -jar /home/ec2-user/devops.jar >> /dev/null & - sleep(10) - curl -X GET 'http://grupo7.drobles.cl/rest/mscovid/test?msg=testing' + - name: Sleep for 10 seconds + uses: jakejarvis/wait-action@master + with: + time: '10s' + - name: Test url using Curl + run: curl -X GET 'http://grupo7.drobles.cl/rest/mscovid/test?msg=testing' + shell: bash + From c917bf30d38263ed9de40bff112d13d462a245d6 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 19:32:45 -0300 Subject: [PATCH 28/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 8432be39..689ad7e3 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -34,8 +34,8 @@ jobs: uses: appleboy/ssh-action@master with: host: drobles.cl - username: ec2-user - password: grupo7 + username: ${{ env.USER }} + password: ${{ env.PASSWORD }} port: 22 script: | sudo /etc/init.d/devops stop || true @@ -48,6 +48,6 @@ jobs: with: time: '10s' - name: Test url using Curl - run: curl -X GET 'http://grupo7.drobles.cl/rest/mscovid/test?msg=testing' + run: curl -X GET 'http://grupo7.drobles.cl/rest/mscovid/estadoPais?pais=chile' shell: bash From f858f5816a7e0553a6f07d6b2a844899c8591af2 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 19:43:57 -0300 Subject: [PATCH 29/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 689ad7e3..234f2a86 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -16,7 +16,9 @@ jobs: with: java-version: '11' distribution: 'temurin' - cache: maven + cache: maven + - name: test2 + run: echo ${{ env.USERNAME }} - name: Deploy run: mvn -B package --file pom.xml - name: Upload application @@ -28,13 +30,11 @@ jobs: port: 22 source: "/home/runner/work/ms-iclab/ms-iclab/build/DevOpsUsach2020-0.0.1.jar" target: "/home/ec2-user/" - - name: test2 - run: echo end - name: Start Service DevOpsUsach2020 uses: appleboy/ssh-action@master with: host: drobles.cl - username: ${{ env.USER }} + username: ${{ env.USERNAME }} password: ${{ env.PASSWORD }} port: 22 script: | From c466861ecdf96ccd678892480e98296deaea5c7e Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 19:47:50 -0300 Subject: [PATCH 30/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 234f2a86..b61e5b08 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -6,7 +6,7 @@ on: jobs: build: - + environment: env runs-on: ubuntu-latest steps: From 4781612752c5955eeca6528cb4ba8e81e65088a7 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 19:49:07 -0300 Subject: [PATCH 31/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index b61e5b08..00d949ef 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -18,15 +18,15 @@ jobs: distribution: 'temurin' cache: maven - name: test2 - run: echo ${{ env.USERNAME }} + run: echo ${{ secret.USERNAME }} - name: Deploy run: mvn -B package --file pom.xml - name: Upload application uses: appleboy/scp-action@master with: host: drobles.cl - username: ec2-user - password: grupo7 + username: ${{ secret.USERNAME }} + password: ${{ secret.PASSWORD }} port: 22 source: "/home/runner/work/ms-iclab/ms-iclab/build/DevOpsUsach2020-0.0.1.jar" target: "/home/ec2-user/" @@ -34,8 +34,8 @@ jobs: uses: appleboy/ssh-action@master with: host: drobles.cl - username: ${{ env.USERNAME }} - password: ${{ env.PASSWORD }} + username: ${{ secret.USERNAME }} + password: ${{ secret.PASSWORD }} port: 22 script: | sudo /etc/init.d/devops stop || true From 55f32918d8fe20be6b3e313358471099128f69bc Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 19:51:13 -0300 Subject: [PATCH 32/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 00d949ef..2b53a0f9 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -18,15 +18,15 @@ jobs: distribution: 'temurin' cache: maven - name: test2 - run: echo ${{ secret.USERNAME }} + run: echo ${{ secrets.USERNAME }} - name: Deploy run: mvn -B package --file pom.xml - name: Upload application uses: appleboy/scp-action@master with: host: drobles.cl - username: ${{ secret.USERNAME }} - password: ${{ secret.PASSWORD }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} port: 22 source: "/home/runner/work/ms-iclab/ms-iclab/build/DevOpsUsach2020-0.0.1.jar" target: "/home/ec2-user/" @@ -34,8 +34,8 @@ jobs: uses: appleboy/ssh-action@master with: host: drobles.cl - username: ${{ secret.USERNAME }} - password: ${{ secret.PASSWORD }} + username: ${{ secrets.USERNAME }} + password: ${{ secrets.PASSWORD }} port: 22 script: | sudo /etc/init.d/devops stop || true From 84238980cc870426d1f32ef7986ee7bd55025179 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 19:55:00 -0300 Subject: [PATCH 33/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index 2b53a0f9..f270101d 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -16,9 +16,7 @@ jobs: with: java-version: '11' distribution: 'temurin' - cache: maven - - name: test2 - run: echo ${{ secrets.USERNAME }} + cache: maven - name: Deploy run: mvn -B package --file pom.xml - name: Upload application @@ -38,7 +36,6 @@ jobs: password: ${{ secrets.PASSWORD }} port: 22 script: | - sudo /etc/init.d/devops stop || true mv /home/ec2-user/devops.jar /home/ec2-user/devops-old.jar || true mv /home/ec2-user/github/workspace/build/DevOpsUsach2020-0.0.1.jar /home/ec2-user/devops.jar killall java From 9cc65566cd1c9148303abf9c6fe9077bf859ce06 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 20:20:33 -0300 Subject: [PATCH 34/92] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2c1524a3..9f1adc83 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Getting Started ## Windows -aaaa +test actions ### Compile Code * ./mvnw.cmd clean compile -e From af795af17614e889e5a5b9bbb5bc73e7e1af9437 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 11 Nov 2022 20:25:28 -0300 Subject: [PATCH 35/92] Update maven-publish.yml --- .github/workflows/maven-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/maven-publish.yml b/.github/workflows/maven-publish.yml index f270101d..90bc65af 100644 --- a/.github/workflows/maven-publish.yml +++ b/.github/workflows/maven-publish.yml @@ -25,7 +25,7 @@ jobs: host: drobles.cl username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} - port: 22 + port: ${{ secrets.PORT }} source: "/home/runner/work/ms-iclab/ms-iclab/build/DevOpsUsach2020-0.0.1.jar" target: "/home/ec2-user/" - name: Start Service DevOpsUsach2020 @@ -34,7 +34,7 @@ jobs: host: drobles.cl username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} - port: 22 + port: ${{ secrets.PORT }} script: | mv /home/ec2-user/devops.jar /home/ec2-user/devops-old.jar || true mv /home/ec2-user/github/workspace/build/DevOpsUsach2020-0.0.1.jar /home/ec2-user/devops.jar From 54303b9d19a202a257d70d14578090a576164d06 Mon Sep 17 00:00:00 2001 From: Daniel Robles Date: Fri, 25 Nov 2022 14:21:20 -0300 Subject: [PATCH 36/92] nueva feature --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b67037b..0e9e0db0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Getting Started -## Windows +## Windowss ### Compile Code * ./mvnw.cmd clean compile -e From 7dbb23a06c408d2e2d022f89355d5c50ad7a1faf Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 25 Nov 2022 16:07:08 -0300 Subject: [PATCH 37/92] Update Jenkinsfile --- Jenkinsfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index fa56d30d..cdeedd41 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -48,6 +48,14 @@ pipeline { } } } + stage("Paso 6: Analizar en Sonar"){ + steps { + withSonarQubeEnv('sonarqube') { + sh "echo 'Llamando a sonar Service!!'" + sh 'sh mvnw clean verify sonar:sonar' + } + } + } } post { always { From 8ef650b6ca6db7d8dab6f6dabcbce8fec7c096c4 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 25 Nov 2022 16:51:21 -0300 Subject: [PATCH 38/92] Update Jenkinsfile --- Jenkinsfile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index cdeedd41..2e7ac321 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,6 +4,9 @@ def jsonParse(def json) { } pipeline { agent any + environment { + //WORKGROUP = credentials('workgroup-name') + } stages { stage("Paso 1: Compilar"){ steps { @@ -57,15 +60,12 @@ pipeline { } } } - post { - always { - sh "echo 'fase always executed post'" - } - success { - sh "echo 'fase success'" + post{ + success{ + slackSend color: 'good', channel: "${env.channel}", message: "[Grupo7] [${JOB_NAME}] [${BUILD_TAG}][Resultado: Éxito/Success]", teamDomain: 'devopsusach20-lzc3526', tokenCredentialId: 'token-slack' } - failure { - sh "echo 'fase failure'" + failure{ + slackSend color: 'danger',channel: "${env.channel}", message: "[Grupo7] [${env.JOB_NAME}] [${env.STAGE}][Resultado: Éxito/Success]", teamDomain: 'devopsusach20-lzc3526', tokenCredentialId: 'token-slack' } } } From c7b0101326c9b9f18073a963e5fa10003fbad33d Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Tue, 29 Nov 2022 17:59:10 -0300 Subject: [PATCH 39/92] Update Jenkinsfile --- Jenkinsfile | 139 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 118 insertions(+), 21 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2e7ac321..924cb825 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,70 +2,167 @@ import groovy.json.JsonSlurperClassic def jsonParse(def json) { new groovy.json.JsonSlurperClassic().parseText(json) } +def current_stage pipeline { agent any environment { - //WORKGROUP = credentials('workgroup-name') + GRUPO_CHANNEL = 'D045253KTEZ' + NOMBRE_GRUPO = 'Grupo 7' } stages { stage("Paso 1: Compilar"){ steps { script { - sh "echo 'Compile Code!'" - // Run Maven on a Unix agent. - sh "./mvnw clean compile -e" + current_stage =env.STAGE_NAME + sh "echo 'Compile Code $TAG_NAME!'" + // Run Maven on a Unix agent. + sh "./mvnw clean compile -e" } } } stage("Paso 2: Testear"){ steps { script { - sh "echo 'Test Code!'" - // Run Maven on a Unix agent. - sh "./mvnw clean test -e" + current_stage =env.STAGE_NAME + sh "echo 'Test Code!'" + sh "plsql" descomentar para fallo + sh "./mvnw clean test -e" } } } stage("Paso 3: Build .Jar"){ steps { script { - sh "echo 'Build .Jar!'" - // Run Maven on a Unix agent. - sh "./mvnw clean package -e" + current_stage =env.STAGE_NAME + sh "echo 'Build .Jar!'" + // Run Maven on a Unix agent. + sh "./mvnw clean package -e" } } } stage("Paso 4: Run .Jar"){ steps { script { - sh "echo 'Running .Jar file!'" - sh "./mvnw spring-boot:run &" + current_stage =env.STAGE_NAME + sh "echo 'Running .Jar file!'" + sh 'nohup bash ./mvnw spring-boot:run & >/dev/null' } } } - stage("Paso 5: Build .Jar"){ + stage("Paso 5: Testing deploy"){ steps { script { - sh "sleep 30" - sh "curl -X GET 'http://localhost:8081/rest/mscovid/estadoPais?pais=Chile'" + current_stage =env.STAGE_NAME + sh "sleep 10" + sh "curl -X GET 'http://jenkins:8081/rest/mscovid/estadoPais?pais=Chile'" } } } - stage("Paso 6: Analizar en Sonar"){ + stage("Paso 6: stop Testing deploy"){ steps { - withSonarQubeEnv('sonarqube') { - sh "echo 'Llamando a sonar Service!!'" - sh 'sh mvnw clean verify sonar:sonar' + script { + current_stage =env.STAGE_NAME + sh ''' + echo 'Process Spring Boot Java: ' $(pidof java | awk '{print $1}') + sleep 20 + kill -9 $(pidof java | awk '{print $1}') ''' + } + } + } + stage("Paso 7: Analizar en Sonar"){ + steps { + script { + current_stage =env.STAGE_NAME + withSonarQubeEnv('sonarqube') { + sh "echo 'Llamando a sonar Service!!'" + sh 'sh mvnw clean verify sonar:sonar -Dsonar.projectKey=com.devopsusach2020:DevOpsUsach2020' + } + } + } + } + stage("Paso 8: Release Subir Artefacto a Nexus"){ + steps { + script { + current_stage =env.STAGE_NAME + //obteniendo version del release + MY_VERSION = env.BRANCH_NAME.substring(8) + sh "echo ${MY_VERSION}" + + nexusPublisher nexusInstanceId: 'maven-ceres-repository', + nexusRepositoryId: 'maven-usach-ceres', + packages: [ + [$class: 'MavenPackage', + mavenAssetList: [ + [classifier: '', + extension: 'jar', + filePath: 'build/DevOpsUsach2020-0.0.1.jar' + ] + ], + mavenCoordinate: [ + artifactId: 'DevOpsUsach2020', + groupId: 'com.devopsusach2020', + packaging: 'jar', + version: MY_VERSION + ] + ] + ] + } + } + } + stage('Paso 9: Descargar ultima version jar de Nexus') { + steps { + script { + current_stage =env.STAGE_NAME + MY_VERSION = env.BRANCH_NAME.substring(8) + sh "echo ${MY_VERSION}" + //sh ' curl -X GET -u $NEXUS_PASSWORD "http://nexus:8081/repository/maven-usach-ceres/com/devopsusach2020/DevOpsUsach2020/0.0.1/DevOpsUsach2020-0.0.1.jar" -O' + //DESCARGANDO LA ULTIMA VERSION JAR pero no me muestra el nombre del jar + //sh 'curl -L -X GET -u $NEXUS_PASSWORD "http://nexus:8081/service/rest/v1/search/assets/download?sort=version&repository=maven-usach-ceres&maven.groupId=com.devopsusach2020&maven.artifactId=DevOpsUsach2020&maven.extension=jar" --output myLastJar.jar' + //otra opcion es obtener la version desde el ultimo tag + //MY_VERSION = sh(returnStdout: true, script: 'git tag --sort=-creatordate | head -n 1').trim() + MY_EXTENSION = ".jar" + //-u $NEXUS_PASSWORD + sh "curl -X GET 'http://nexus:8081/repository/maven-usach-ceres/com/devopsusach2020/DevOpsUsach2020/$MY_VERSION/DevOpsUsach2020-$MY_VERSION$MY_EXTENSION' -O" + + } + } + } + stage('Paso 10: Levantar y testear Artefacto Jar obtenido de nexus') { + steps { + script { + NOMBRE_STAGE = 'Levantar y testear Artefacto Jar obtenido de nexus' + sh "nohup java -jar DevOpsUsach2020-$MY_VERSION$MY_EXTENSION & >/dev/null" + sh "sleep 20 && curl -X GET 'http://jenkins:8081/rest/mscovid/test?msg=testing'" + } + } + } + stage('Paso 11:Detener Atefacto jar en Jenkins server') { + steps { + script { + current_stage =env.STAGE_NAME + sh ''' + echo 'Process Java .jar: ' $(pidof java | awk '{print $1}') + sleep 20 + kill -9 $(pidof java | awk '{print $1}') + ''' + } + } + } + stage('Paso 12: Deploy Prod') { + steps { + script { + current_stage =env.STAGE_NAME + sh "echo 'enviado a PROD $MY_VERSION'" } } } } post{ success{ - slackSend color: 'good', channel: "${env.channel}", message: "[Grupo7] [${JOB_NAME}] [${BUILD_TAG}][Resultado: Éxito/Success]", teamDomain: 'devopsusach20-lzc3526', tokenCredentialId: 'token-slack' + slackSend color: 'good', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado: Éxito/Success](<${env.BUILD_URL}|Detalle>)", tokenCredentialId: 'id-token-slack' } failure{ - slackSend color: 'danger',channel: "${env.channel}", message: "[Grupo7] [${env.JOB_NAME}] [${env.STAGE}][Resultado: Éxito/Success]", teamDomain: 'devopsusach20-lzc3526', tokenCredentialId: 'token-slack' + slackSend color: 'danger', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado:Error/Fail](<${env.BUILD_URL}|Detalle>)", tokenCredentialId: 'id-token-slack' } } } From 7fabe2282f47bbaaa5ea0222b66790800dc83f00 Mon Sep 17 00:00:00 2001 From: Yrma Ccencho Date: Tue, 29 Nov 2022 22:44:18 -0300 Subject: [PATCH 40/92] jenkisfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 924cb825..d753d1f1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,7 +25,7 @@ pipeline { script { current_stage =env.STAGE_NAME sh "echo 'Test Code!'" - sh "plsql" descomentar para fallo + //sh "plsql" descomentar para fallo sh "./mvnw clean test -e" } } From 2d6c73dab9d95504f8943b030a68cb4add97fd21 Mon Sep 17 00:00:00 2001 From: Yrma Ccencho Date: Tue, 29 Nov 2022 22:47:34 -0300 Subject: [PATCH 41/92] jenkisfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d753d1f1..27590a0f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,7 +14,7 @@ pipeline { steps { script { current_stage =env.STAGE_NAME - sh "echo 'Compile Code $TAG_NAME!'" + sh "echo 'Compile Code'" // Run Maven on a Unix agent. sh "./mvnw clean compile -e" } From e677ae84ca61d9eddaca833e9437f4620b21f8ae Mon Sep 17 00:00:00 2001 From: yrma2102 <42274589+yrma2102@users.noreply.github.com> Date: Wed, 30 Nov 2022 18:48:27 -0300 Subject: [PATCH 42/92] git flow steps --- Jenkinsfile | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 27590a0f..c2d8b75f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -156,6 +156,52 @@ pipeline { } } } + stage('Paso 12: git merge to main and develop and create tag') { + steps { + withCredentials([ + gitUsernamePassword(credentialsId: 'github-jenkins', gitToolName: 'Default') + ]) { + script{ + //git flow steps + //Release branch has been merged into 'main' + sh "git checkout ${env.BRANCH_NAME}" + sh "git pull origin" + //sh "git clean -f" + + sh "git checkout main" + sh "git fetch origin" + sh "git pull origin main" + sh "git merge ${env.BRANCH_NAME}" + sh "git push origin main" + + //The release was tagged with release version name + //traer el ultimo tag del origin + MY_VERSION_TAG = sh(returnStdout: true, script: 'git tag --sort=-creatordate | head -n 1').trim() + if (MY_VERSION_TAG == MY_VERSION) { + sh "git tag -d ${MY_VERSION}" + sh "git push --delete origin ${MY_VERSION}" + sh "git tag -a $MY_VERSION -m 'update release from Jenkins'" + sh "git push origin $MY_VERSION" + } else { + sh "git tag -a $MY_VERSION -m 'update release from Jenkins'" + sh "git push origin $MY_VERSION" + } + + //Release tag has been back-merged into 'develop' + sh "git checkout develop" + sh "git pull origin develop" + sh "git merge ${env.BRANCH_NAME}" + sh "git push origin develop" + + //Release branch has been remotely deleted from 'origin' + sh "git push origin --delete ${env.BRANCH_NAME}" + } + + + + } + } + } } post{ success{ From c75069234b9e3cfadcf6feb7f6f42da04ca884a7 Mon Sep 17 00:00:00 2001 From: yrma2102 <42274589+yrma2102@users.noreply.github.com> Date: Wed, 30 Nov 2022 19:08:59 -0300 Subject: [PATCH 43/92] Update Jenkinsfile --- Jenkinsfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index c2d8b75f..698adfbc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -162,8 +162,11 @@ pipeline { gitUsernamePassword(credentialsId: 'github-jenkins', gitToolName: 'Default') ]) { script{ + current_stage =env.STAGE_NAME //git flow steps //Release branch has been merged into 'main' + sh "git config --global user.email 'yrma.2102@gmail.com'" + sh "git config --global user.name 'Yrma'" sh "git checkout ${env.BRANCH_NAME}" sh "git pull origin" //sh "git clean -f" From 13923701d62c303ddff32c17465607f8e75ee10b Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Wed, 30 Nov 2022 20:22:10 -0300 Subject: [PATCH 44/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index c2d8b75f..aa40be21 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -54,7 +54,7 @@ pipeline { script { current_stage =env.STAGE_NAME sh "sleep 10" - sh "curl -X GET 'http://jenkins:8081/rest/mscovid/estadoPais?pais=Chile'" + sh "curl -X GET 'http://localhost:8081/rest/mscovid/estadoPais?pais=Chile'" } } } From 4dfe80ce0cac6523614829a257394582be7c821a Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Thu, 1 Dec 2022 14:13:48 -0300 Subject: [PATCH 45/92] Update Jenkinsfile --- Jenkinsfile | 105 +++++++++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 59 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 240ffde8..21766d7d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,6 +6,8 @@ def current_stage pipeline { agent any environment { + GITHUB_EMAIL = credentials('GITHUB_EMAIL') + GITHUB_USERNAME = credentials('GITHUB_USERNAME') GRUPO_CHANNEL = 'D045253KTEZ' NOMBRE_GRUPO = 'Grupo 7' } @@ -14,8 +16,7 @@ pipeline { steps { script { current_stage =env.STAGE_NAME - sh "echo 'Compile Code'" - // Run Maven on a Unix agent. + sh "echo 'Stage 1: Compiling code!'" sh "./mvnw clean compile -e" } } @@ -24,7 +25,7 @@ pipeline { steps { script { current_stage =env.STAGE_NAME - sh "echo 'Test Code!'" + sh "echo 'Stage 2: Testing code!'" //sh "plsql" descomentar para fallo sh "./mvnw clean test -e" } @@ -34,8 +35,7 @@ pipeline { steps { script { current_stage =env.STAGE_NAME - sh "echo 'Build .Jar!'" - // Run Maven on a Unix agent. + sh "echo 'Stage 3: Building .Jar file!'" sh "./mvnw clean package -e" } } @@ -44,8 +44,8 @@ pipeline { steps { script { current_stage =env.STAGE_NAME - sh "echo 'Running .Jar file!'" - sh 'nohup bash ./mvnw spring-boot:run & >/dev/null' + sh "echo 'Stage 4: Running .Jar file!'" + sh "nohup bash ./mvnw spring-boot:run & >/dev/null" } } } @@ -53,6 +53,7 @@ pipeline { steps { script { current_stage =env.STAGE_NAME + sh "echo 'Stage 5: Testing deploy!'" sh "sleep 10" sh "curl -X GET 'http://localhost:8081/rest/mscovid/estadoPais?pais=Chile'" } @@ -62,10 +63,9 @@ pipeline { steps { script { current_stage =env.STAGE_NAME - sh ''' - echo 'Process Spring Boot Java: ' $(pidof java | awk '{print $1}') - sleep 20 - kill -9 $(pidof java | awk '{print $1}') ''' + sh "echo 'Stage 6: Stopping jar running'" + sh "sleep 10" + sh "kill -9 $(pidof java | awk '{print $1}')" } } } @@ -74,7 +74,7 @@ pipeline { script { current_stage =env.STAGE_NAME withSonarQubeEnv('sonarqube') { - sh "echo 'Llamando a sonar Service!!'" + sh "echo 'Stage 7: Static code analysis in Sonar'" sh 'sh mvnw clean verify sonar:sonar -Dsonar.projectKey=com.devopsusach2020:DevOpsUsach2020' } } @@ -84,10 +84,8 @@ pipeline { steps { script { current_stage =env.STAGE_NAME - //obteniendo version del release + sh "echo 'Stage 8:Uploading artifact to Nexus'" MY_VERSION = env.BRANCH_NAME.substring(8) - sh "echo ${MY_VERSION}" - nexusPublisher nexusInstanceId: 'maven-ceres-repository', nexusRepositoryId: 'maven-usach-ceres', packages: [ @@ -113,15 +111,9 @@ pipeline { steps { script { current_stage =env.STAGE_NAME + sh "echo 'Stage 9:Downloading artifact from Nexus'" MY_VERSION = env.BRANCH_NAME.substring(8) - sh "echo ${MY_VERSION}" - //sh ' curl -X GET -u $NEXUS_PASSWORD "http://nexus:8081/repository/maven-usach-ceres/com/devopsusach2020/DevOpsUsach2020/0.0.1/DevOpsUsach2020-0.0.1.jar" -O' - //DESCARGANDO LA ULTIMA VERSION JAR pero no me muestra el nombre del jar - //sh 'curl -L -X GET -u $NEXUS_PASSWORD "http://nexus:8081/service/rest/v1/search/assets/download?sort=version&repository=maven-usach-ceres&maven.groupId=com.devopsusach2020&maven.artifactId=DevOpsUsach2020&maven.extension=jar" --output myLastJar.jar' - //otra opcion es obtener la version desde el ultimo tag - //MY_VERSION = sh(returnStdout: true, script: 'git tag --sort=-creatordate | head -n 1').trim() MY_EXTENSION = ".jar" - //-u $NEXUS_PASSWORD sh "curl -X GET 'http://nexus:8081/repository/maven-usach-ceres/com/devopsusach2020/DevOpsUsach2020/$MY_VERSION/DevOpsUsach2020-$MY_VERSION$MY_EXTENSION' -O" } @@ -130,7 +122,8 @@ pipeline { stage('Paso 10: Levantar y testear Artefacto Jar obtenido de nexus') { steps { script { - NOMBRE_STAGE = 'Levantar y testear Artefacto Jar obtenido de nexus' + current_stage =env.STAGE_NAME + sh "echo 'Stage 10:Testing artifact downloaded from Nexus'" sh "nohup java -jar DevOpsUsach2020-$MY_VERSION$MY_EXTENSION & >/dev/null" sh "sleep 20 && curl -X GET 'http://jenkins:8081/rest/mscovid/test?msg=testing'" } @@ -140,47 +133,44 @@ pipeline { steps { script { current_stage =env.STAGE_NAME - sh ''' - echo 'Process Java .jar: ' $(pidof java | awk '{print $1}') - sleep 20 - kill -9 $(pidof java | awk '{print $1}') - ''' + sh "echo 'Stage 11: Stopping artifact')" + sh "sleep 10" + sh "kill -9 $(pidof java | awk '{print $1}')" } } } - stage('Paso 12: Deploy Prod') { + stage('Paso 12: Desplegar en Produccion') { steps { script { current_stage =env.STAGE_NAME - sh "echo 'enviado a PROD $MY_VERSION'" + sh "echo 'Stage 12: Deploying on production" + sh "echo 'enviado a produccion $MY_VERSION'" } } } - stage('Paso 12: git merge to main and develop and create tag') { + stage('Paso 13: Hacer merge con develop y main y aplicar tag') { steps { withCredentials([ gitUsernamePassword(credentialsId: 'github-jenkins', gitToolName: 'Default') ]) { script{ current_stage =env.STAGE_NAME - //git flow steps - //Release branch has been merged into 'main' - sh "git config --global user.email 'yrma.2102@gmail.com'" - sh "git config --global user.name 'Yrma'" - sh "git checkout ${env.BRANCH_NAME}" - sh "git pull origin" - //sh "git clean -f" - - sh "git checkout main" - sh "git fetch origin" - sh "git pull origin main" - sh "git merge ${env.BRANCH_NAME}" - sh "git push origin main" + sh "echo 'Stage 13: Merging branch on main and develop and create tag" + //Release branch has been merged into '$GITHUB_EMAIL' + sh "git config --global user.email '$GITHUB_EMAIL'" + sh "git config --global user.name '$GITHUB_USERNAME'" + sh "git checkout ${env.BRANCH_NAME}" + sh "git pull origin" + + sh "git checkout main" + sh "git fetch origin" + sh "git pull origin main" + sh "git merge ${env.BRANCH_NAME}" + sh "git push origin main" - //The release was tagged with release version name - //traer el ultimo tag del origin - MY_VERSION_TAG = sh(returnStdout: true, script: 'git tag --sort=-creatordate | head -n 1').trim() - if (MY_VERSION_TAG == MY_VERSION) { + //traer el ultimo tag del origin + MY_VERSION_TAG = sh(returnStdout: true, script: 'git tag --sort=-creatordate | head -n 1').trim() + if (MY_VERSION_TAG == MY_VERSION) { sh "git tag -d ${MY_VERSION}" sh "git push --delete origin ${MY_VERSION}" sh "git tag -a $MY_VERSION -m 'update release from Jenkins'" @@ -190,18 +180,15 @@ pipeline { sh "git push origin $MY_VERSION" } - //Release tag has been back-merged into 'develop' - sh "git checkout develop" - sh "git pull origin develop" - sh "git merge ${env.BRANCH_NAME}" - sh "git push origin develop" - - //Release branch has been remotely deleted from 'origin' - sh "git push origin --delete ${env.BRANCH_NAME}" - } - - + //Release tag has been back-merged into 'develop' + sh "git checkout develop" + sh "git pull origin develop" + sh "git merge ${env.BRANCH_NAME}" + sh "git push origin develop" + //Release branch has been remotely deleted from 'origin' + sh "git push origin --delete ${env.BRANCH_NAME}" + } } } } From 0a7109e5260289f997d17fa9dc1a33405049a827 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Thu, 1 Dec 2022 14:39:55 -0300 Subject: [PATCH 46/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 21766d7d..d583ba06 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -135,7 +135,7 @@ pipeline { current_stage =env.STAGE_NAME sh "echo 'Stage 11: Stopping artifact')" sh "sleep 10" - sh "kill -9 $(pidof java | awk '{print $1}')" + sh "kill -9 $(pidof java | awk ''{print $1}'')" } } } From fe935f87582e680b92657bcd61c81998d6f1ae25 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Thu, 1 Dec 2022 14:42:29 -0300 Subject: [PATCH 47/92] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d583ba06..f736392c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -65,7 +65,7 @@ pipeline { current_stage =env.STAGE_NAME sh "echo 'Stage 6: Stopping jar running'" sh "sleep 10" - sh "kill -9 $(pidof java | awk '{print $1}')" + sh "kill -9 $(pidof java | awk \'{print $1}\')" } } } @@ -135,7 +135,7 @@ pipeline { current_stage =env.STAGE_NAME sh "echo 'Stage 11: Stopping artifact')" sh "sleep 10" - sh "kill -9 $(pidof java | awk ''{print $1}'')" + sh "kill -9 $(pidof java | awk '{print $1}')" } } } From 291e91e29468f0a1c77738e7c43db3cf7df92332 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Thu, 1 Dec 2022 14:43:47 -0300 Subject: [PATCH 48/92] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f736392c..fa022e13 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -65,7 +65,7 @@ pipeline { current_stage =env.STAGE_NAME sh "echo 'Stage 6: Stopping jar running'" sh "sleep 10" - sh "kill -9 $(pidof java | awk \'{print $1}\')" + sh '''kill -9 $(pidof java | awk '{print $1}')''' } } } @@ -135,7 +135,7 @@ pipeline { current_stage =env.STAGE_NAME sh "echo 'Stage 11: Stopping artifact')" sh "sleep 10" - sh "kill -9 $(pidof java | awk '{print $1}')" + sh '''kill -9 $(pidof java | awk '{print $1}')''' } } } From ef671c226545881b4cf472eaf43050cee3f9224a Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Thu, 1 Dec 2022 14:55:28 -0300 Subject: [PATCH 49/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index fa022e13..4e5d5ead 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -133,7 +133,7 @@ pipeline { steps { script { current_stage =env.STAGE_NAME - sh "echo 'Stage 11: Stopping artifact')" + sh "echo 'Stage 11: Stopping artifact'" sh "sleep 10" sh '''kill -9 $(pidof java | awk '{print $1}')''' } From f128ec00ee12c054ac9f8db99b4e7020665cbf6c Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Thu, 1 Dec 2022 15:12:27 -0300 Subject: [PATCH 50/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4e5d5ead..1bb909dc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -143,7 +143,7 @@ pipeline { steps { script { current_stage =env.STAGE_NAME - sh "echo 'Stage 12: Deploying on production" + sh "echo 'Stage 12: Deploying on production'" sh "echo 'enviado a produccion $MY_VERSION'" } } From 199fc349c6c120ccd825b8244aaabc391a157e09 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Thu, 1 Dec 2022 15:19:21 -0300 Subject: [PATCH 51/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1bb909dc..23e066da 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -155,7 +155,7 @@ pipeline { ]) { script{ current_stage =env.STAGE_NAME - sh "echo 'Stage 13: Merging branch on main and develop and create tag" + sh "echo 'Stage 13: Merging branch on main and develop and create tag'" //Release branch has been merged into '$GITHUB_EMAIL' sh "git config --global user.email '$GITHUB_EMAIL'" sh "git config --global user.name '$GITHUB_USERNAME'" From c1a2e406b037f784b6db4fa9ad601910857a3a46 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 10:19:25 -0300 Subject: [PATCH 52/92] Update Jenkinsfile --- Jenkinsfile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 23e066da..fe0554c4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,6 +3,7 @@ def jsonParse(def json) { new groovy.json.JsonSlurperClassic().parseText(json) } def current_stage +def build_duration_msg pipeline { agent any environment { @@ -18,6 +19,7 @@ pipeline { current_stage =env.STAGE_NAME sh "echo 'Stage 1: Compiling code!'" sh "./mvnw clean compile -e" + build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString \n } } } @@ -28,6 +30,7 @@ pipeline { sh "echo 'Stage 2: Testing code!'" //sh "plsql" descomentar para fallo sh "./mvnw clean test -e" + build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString \n } } } @@ -37,6 +40,7 @@ pipeline { current_stage =env.STAGE_NAME sh "echo 'Stage 3: Building .Jar file!'" sh "./mvnw clean package -e" + build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString \n } } } @@ -195,10 +199,10 @@ pipeline { } post{ success{ - slackSend color: 'good', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado: Éxito/Success](<${env.BUILD_URL}|Detalle>)", tokenCredentialId: 'id-token-slack' + slackSend color: 'good', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado: Éxito/Success]${build_duration_stage}(<${env.BUILD_URL}|Detalle>)", tokenCredentialId: 'id-token-slack' } failure{ - slackSend color: 'danger', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado:Error/Fail](<${env.BUILD_URL}|Detalle>)", tokenCredentialId: 'id-token-slack' + slackSend color: 'danger', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado:Error/Fail]${build_duration_stage}(<${env.BUILD_URL}|Detalle>)", tokenCredentialId: 'id-token-slack' } } } From d2bded1837569d881386eb2943a5a72523e0052d Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 10:22:10 -0300 Subject: [PATCH 53/92] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fe0554c4..9b7faad1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,7 +19,7 @@ pipeline { current_stage =env.STAGE_NAME sh "echo 'Stage 1: Compiling code!'" sh "./mvnw clean compile -e" - build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString \n + build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString +"\n" } } } @@ -30,7 +30,7 @@ pipeline { sh "echo 'Stage 2: Testing code!'" //sh "plsql" descomentar para fallo sh "./mvnw clean test -e" - build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString \n + build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString +"\n" } } } From 4c671850ca20350774cbbfff1b2ddd0dc640e762 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 10:25:06 -0300 Subject: [PATCH 54/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9b7faad1..8b123074 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,7 +40,7 @@ pipeline { current_stage =env.STAGE_NAME sh "echo 'Stage 3: Building .Jar file!'" sh "./mvnw clean package -e" - build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString \n + build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString + "\n" } } } From d50bd4ba09102574edb35ff56ff5f101829e0fc2 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 10:30:40 -0300 Subject: [PATCH 55/92] Update Jenkinsfile --- Jenkinsfile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8b123074..d2bd2d2f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -19,6 +19,7 @@ pipeline { current_stage =env.STAGE_NAME sh "echo 'Stage 1: Compiling code!'" sh "./mvnw clean compile -e" + sh "echo ${build_duration_msg}" build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString +"\n" } } @@ -30,6 +31,7 @@ pipeline { sh "echo 'Stage 2: Testing code!'" //sh "plsql" descomentar para fallo sh "./mvnw clean test -e" + sh "echo ${build_duration_msg}" build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString +"\n" } } @@ -199,10 +201,10 @@ pipeline { } post{ success{ - slackSend color: 'good', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado: Éxito/Success]${build_duration_stage}(<${env.BUILD_URL}|Detalle>)", tokenCredentialId: 'id-token-slack' + slackSend color: 'good', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado: Éxito/Success](<${env.BUILD_URL}|Detalle>)${build_duration_msg}", tokenCredentialId: 'id-token-slack' } failure{ - slackSend color: 'danger', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado:Error/Fail]${build_duration_stage}(<${env.BUILD_URL}|Detalle>)", tokenCredentialId: 'id-token-slack' + slackSend color: 'danger', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado:Error/Fail](<${env.BUILD_URL}|Detalle>)${build_duration_msg}", tokenCredentialId: 'id-token-slack' } } } From 93a4b23c78b53411c6b2c026e0cdc0a890e2b372 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 11:34:04 -0300 Subject: [PATCH 56/92] Update Jenkinsfile --- Jenkinsfile | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d2bd2d2f..26b10ec3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,7 @@ def jsonParse(def json) { new groovy.json.JsonSlurperClassic().parseText(json) } def current_stage -def build_duration_msg +def build_duration_msg = "\n *Detail by stage* \n" pipeline { agent any environment { @@ -16,23 +16,26 @@ pipeline { stage("Paso 1: Compilar"){ steps { script { + start = System.currentTimeMillis() current_stage =env.STAGE_NAME sh "echo 'Stage 1: Compiling code!'" sh "./mvnw clean compile -e" - sh "echo ${build_duration_msg}" - build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString +"\n" + end = System.currentTimeMillis() + build_duration_msg = "*" current_stage + "*" + " : " + ${Util.getTimeSpanString(start - end)} +"\n" } } } stage("Paso 2: Testear"){ steps { script { + start = System.currentTimeMillis() current_stage =env.STAGE_NAME sh "echo 'Stage 2: Testing code!'" - //sh "plsql" descomentar para fallo + sh "plsql" descomentar para fallo sh "./mvnw clean test -e" sh "echo ${build_duration_msg}" - build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString +"\n" + end = System.currentTimeMillis() + build_duration_msg = + build_duration_msg + "*" current_stage + "*" + " : " + ${Util.getTimeSpanString(start - end)} +"\n" } } } @@ -40,6 +43,7 @@ pipeline { steps { script { current_stage =env.STAGE_NAME + sh "plsql" descomentar para fallo sh "echo 'Stage 3: Building .Jar file!'" sh "./mvnw clean package -e" build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString + "\n" From b6e7e5385aaafbc58036dd5809ffb7b646212ef3 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 11:34:38 -0300 Subject: [PATCH 57/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 26b10ec3..34ce8db9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -197,7 +197,7 @@ pipeline { sh "git push origin develop" //Release branch has been remotely deleted from 'origin' - sh "git push origin --delete ${env.BRANCH_NAME}" + // sh "git push origin --delete ${env.BRANCH_NAME}" } } } From 2eaac8f6f404fc25dbf504f6447fa3727e09209e Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 11:35:37 -0300 Subject: [PATCH 58/92] Update Jenkinsfile --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 34ce8db9..7cf5b71c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -181,12 +181,12 @@ pipeline { //traer el ultimo tag del origin MY_VERSION_TAG = sh(returnStdout: true, script: 'git tag --sort=-creatordate | head -n 1').trim() if (MY_VERSION_TAG == MY_VERSION) { - sh "git tag -d ${MY_VERSION}" + // sh "git tag -d ${MY_VERSION}" sh "git push --delete origin ${MY_VERSION}" - sh "git tag -a $MY_VERSION -m 'update release from Jenkins'" + // sh "git tag -a $MY_VERSION -m 'update release from Jenkins'" sh "git push origin $MY_VERSION" } else { - sh "git tag -a $MY_VERSION -m 'update release from Jenkins'" + // sh "git tag -a $MY_VERSION -m 'update release from Jenkins'" sh "git push origin $MY_VERSION" } From ddfc2f656280fdec109c8293ec91bba993f50f92 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 11:38:55 -0300 Subject: [PATCH 59/92] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7cf5b71c..d27e3361 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,7 @@ pipeline { sh "echo 'Stage 1: Compiling code!'" sh "./mvnw clean compile -e" end = System.currentTimeMillis() - build_duration_msg = "*" current_stage + "*" + " : " + ${Util.getTimeSpanString(start - end)} +"\n" + build_duration_msg = "*" + current_stage + "*" + " : " + ${Util.getTimeSpanString(start - end)} +"\n" } } } @@ -35,7 +35,7 @@ pipeline { sh "./mvnw clean test -e" sh "echo ${build_duration_msg}" end = System.currentTimeMillis() - build_duration_msg = + build_duration_msg + "*" current_stage + "*" + " : " + ${Util.getTimeSpanString(start - end)} +"\n" + build_duration_msg = + build_duration_msg + "*" + current_stage + "*" + " : " + ${Util.getTimeSpanString(start - end)} +"\n" } } } From b6bdd7cf1b9ece5d491c8322654813caa6887ff3 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 11:39:50 -0300 Subject: [PATCH 60/92] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7cf5b71c..d27e3361 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,7 @@ pipeline { sh "echo 'Stage 1: Compiling code!'" sh "./mvnw clean compile -e" end = System.currentTimeMillis() - build_duration_msg = "*" current_stage + "*" + " : " + ${Util.getTimeSpanString(start - end)} +"\n" + build_duration_msg = "*" + current_stage + "*" + " : " + ${Util.getTimeSpanString(start - end)} +"\n" } } } @@ -35,7 +35,7 @@ pipeline { sh "./mvnw clean test -e" sh "echo ${build_duration_msg}" end = System.currentTimeMillis() - build_duration_msg = + build_duration_msg + "*" current_stage + "*" + " : " + ${Util.getTimeSpanString(start - end)} +"\n" + build_duration_msg = + build_duration_msg + "*" + current_stage + "*" + " : " + ${Util.getTimeSpanString(start - end)} +"\n" } } } From f27bbb73e0544cec31039c07f46587ac96fae641 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 11:41:56 -0300 Subject: [PATCH 61/92] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d27e3361..cb2194c5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,7 +21,7 @@ pipeline { sh "echo 'Stage 1: Compiling code!'" sh "./mvnw clean compile -e" end = System.currentTimeMillis() - build_duration_msg = "*" + current_stage + "*" + " : " + ${Util.getTimeSpanString(start - end)} +"\n" + build_duration_msg = "*" + current_stage + "*" + " : " + Util.getTimeSpanString(start - end) +"\n" } } } @@ -35,7 +35,7 @@ pipeline { sh "./mvnw clean test -e" sh "echo ${build_duration_msg}" end = System.currentTimeMillis() - build_duration_msg = + build_duration_msg + "*" + current_stage + "*" + " : " + ${Util.getTimeSpanString(start - end)} +"\n" + build_duration_msg = + build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(start - end) +"\n" } } } From 7a247b43aa090308f664dda4689d211dcc37d5b1 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 11:48:29 -0300 Subject: [PATCH 62/92] Update Jenkinsfile --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index cb2194c5..f0557c0e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,5 @@ import groovy.json.JsonSlurperClassic +import Util def jsonParse(def json) { new groovy.json.JsonSlurperClassic().parseText(json) } From a521c4b26c88938b96a22829921ec095f77ab926 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 11:50:50 -0300 Subject: [PATCH 63/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f0557c0e..bf1e0e23 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ import groovy.json.JsonSlurperClassic -import Util +import hudson.model.* def jsonParse(def json) { new groovy.json.JsonSlurperClassic().parseText(json) } From 331e6a31208bf5332ac58ef1682a8dc249273c04 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 11:54:18 -0300 Subject: [PATCH 64/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index bf1e0e23..b48cf7f3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ import groovy.json.JsonSlurperClassic -import hudson.model.* +import hudson.Util.* def jsonParse(def json) { new groovy.json.JsonSlurperClassic().parseText(json) } From 76663b0448abc9f572742c98ff270ffa0ef1c950 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 11:57:24 -0300 Subject: [PATCH 65/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index b48cf7f3..8b8e861c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ import groovy.json.JsonSlurperClassic -import hudson.Util.* +import hudson.Util; def jsonParse(def json) { new groovy.json.JsonSlurperClassic().parseText(json) } From 488407a245f9f8c1cb260b877eb8af2f18514d08 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 12:02:15 -0300 Subject: [PATCH 66/92] Update Jenkinsfile --- Jenkinsfile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8b8e861c..c7b89d40 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,7 +22,7 @@ pipeline { sh "echo 'Stage 1: Compiling code!'" sh "./mvnw clean compile -e" end = System.currentTimeMillis() - build_duration_msg = "*" + current_stage + "*" + " : " + Util.getTimeSpanString(start - end) +"\n" + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } @@ -31,12 +31,11 @@ pipeline { script { start = System.currentTimeMillis() current_stage =env.STAGE_NAME - sh "echo 'Stage 2: Testing code!'" - sh "plsql" descomentar para fallo + sh "echo 'Stage 2: Testing code!'" sh "./mvnw clean test -e" sh "echo ${build_duration_msg}" end = System.currentTimeMillis() - build_duration_msg = + build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(start - end) +"\n" + build_duration_msg = + build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } @@ -44,7 +43,7 @@ pipeline { steps { script { current_stage =env.STAGE_NAME - sh "plsql" descomentar para fallo + sh "plsql" //descomentar para fallo sh "echo 'Stage 3: Building .Jar file!'" sh "./mvnw clean package -e" build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString + "\n" From 20e0c3cd5266921ae97e55131f9e8fab275ac6b2 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 12:16:09 -0300 Subject: [PATCH 67/92] Update Jenkinsfile --- Jenkinsfile | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c7b89d40..e9f7629e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -42,57 +42,71 @@ pipeline { stage("Paso 3: Build .Jar"){ steps { script { + start = System.currentTimeMillis() current_stage =env.STAGE_NAME - sh "plsql" //descomentar para fallo sh "echo 'Stage 3: Building .Jar file!'" sh "./mvnw clean package -e" - build_duration_msg = build_duration_msg + current_stage + " : " + currentBuild.durationString + "\n" + end = System.currentTimeMillis() + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } stage("Paso 4: Run .Jar"){ steps { script { + start = System.currentTimeMillis() current_stage =env.STAGE_NAME sh "echo 'Stage 4: Running .Jar file!'" sh "nohup bash ./mvnw spring-boot:run & >/dev/null" + end = System.currentTimeMillis() + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } stage("Paso 5: Testing deploy"){ steps { script { + start = System.currentTimeMillis() current_stage =env.STAGE_NAME sh "echo 'Stage 5: Testing deploy!'" sh "sleep 10" sh "curl -X GET 'http://localhost:8081/rest/mscovid/estadoPais?pais=Chile'" + end = System.currentTimeMillis() + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } stage("Paso 6: stop Testing deploy"){ steps { script { + start = System.currentTimeMillis() current_stage =env.STAGE_NAME sh "echo 'Stage 6: Stopping jar running'" sh "sleep 10" sh '''kill -9 $(pidof java | awk '{print $1}')''' + end = System.currentTimeMillis() + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } stage("Paso 7: Analizar en Sonar"){ steps { script { + start = System.currentTimeMillis() current_stage =env.STAGE_NAME withSonarQubeEnv('sonarqube') { sh "echo 'Stage 7: Static code analysis in Sonar'" sh 'sh mvnw clean verify sonar:sonar -Dsonar.projectKey=com.devopsusach2020:DevOpsUsach2020' } + end = System.currentTimeMillis() + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } stage("Paso 8: Release Subir Artefacto a Nexus"){ steps { script { + start = System.currentTimeMillis() current_stage =env.STAGE_NAME sh "echo 'Stage 8:Uploading artifact to Nexus'" MY_VERSION = env.BRANCH_NAME.substring(8) @@ -114,47 +128,60 @@ pipeline { ] ] ] + end = System.currentTimeMillis() + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } stage('Paso 9: Descargar ultima version jar de Nexus') { steps { script { + start = System.currentTimeMillis() current_stage =env.STAGE_NAME sh "echo 'Stage 9:Downloading artifact from Nexus'" MY_VERSION = env.BRANCH_NAME.substring(8) MY_EXTENSION = ".jar" sh "curl -X GET 'http://nexus:8081/repository/maven-usach-ceres/com/devopsusach2020/DevOpsUsach2020/$MY_VERSION/DevOpsUsach2020-$MY_VERSION$MY_EXTENSION' -O" - + end = System.currentTimeMillis() + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } stage('Paso 10: Levantar y testear Artefacto Jar obtenido de nexus') { steps { script { + start = System.currentTimeMillis() current_stage =env.STAGE_NAME sh "echo 'Stage 10:Testing artifact downloaded from Nexus'" sh "nohup java -jar DevOpsUsach2020-$MY_VERSION$MY_EXTENSION & >/dev/null" sh "sleep 20 && curl -X GET 'http://jenkins:8081/rest/mscovid/test?msg=testing'" + end = System.currentTimeMillis() + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } stage('Paso 11:Detener Atefacto jar en Jenkins server') { steps { script { + start = System.currentTimeMillis() current_stage =env.STAGE_NAME sh "echo 'Stage 11: Stopping artifact'" sh "sleep 10" sh '''kill -9 $(pidof java | awk '{print $1}')''' + end = System.currentTimeMillis() + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } stage('Paso 12: Desplegar en Produccion') { steps { script { + start = System.currentTimeMillis() current_stage =env.STAGE_NAME sh "echo 'Stage 12: Deploying on production'" sh "echo 'enviado a produccion $MY_VERSION'" + end = System.currentTimeMillis() + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } @@ -164,6 +191,7 @@ pipeline { gitUsernamePassword(credentialsId: 'github-jenkins', gitToolName: 'Default') ]) { script{ + start = System.currentTimeMillis() current_stage =env.STAGE_NAME sh "echo 'Stage 13: Merging branch on main and develop and create tag'" //Release branch has been merged into '$GITHUB_EMAIL' @@ -199,11 +227,16 @@ pipeline { //Release branch has been remotely deleted from 'origin' // sh "git push origin --delete ${env.BRANCH_NAME}" } + end = System.currentTimeMillis() + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } } post{ + always{ + build_duration_msg = build_duration_msg + "\n *Total build time:* " + "${currentBuild.durationString}".replaceAll(' and counting', "") + } success{ slackSend color: 'good', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado: Éxito/Success](<${env.BUILD_URL}|Detalle>)${build_duration_msg}", tokenCredentialId: 'id-token-slack' } From 7fd4224ef2300b2905788ba4c79ed10ddf460cb7 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 12:19:36 -0300 Subject: [PATCH 68/92] Update Jenkinsfile --- Jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e9f7629e..ba158c5d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -226,9 +226,10 @@ pipeline { //Release branch has been remotely deleted from 'origin' // sh "git push origin --delete ${env.BRANCH_NAME}" + end = System.currentTimeMillis() + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } - end = System.currentTimeMillis() - build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" + } } } From df4ef7e905be1b936c36a09df8f3556afdd2e72e Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 12:22:49 -0300 Subject: [PATCH 69/92] Update Jenkinsfile --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ba158c5d..3786913d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -236,7 +236,9 @@ pipeline { } post{ always{ - build_duration_msg = build_duration_msg + "\n *Total build time:* " + "${currentBuild.durationString}".replaceAll(' and counting', "") + script{ + build_duration_msg = build_duration_msg + "\n *Total build time:* " + "${currentBuild.durationString}".replaceAll(' and counting', "") + } } success{ slackSend color: 'good', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado: Éxito/Success](<${env.BUILD_URL}|Detalle>)${build_duration_msg}", tokenCredentialId: 'id-token-slack' From d80debbf9a6f219c9cc5584a57f92a6d04fcffd0 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 12:32:43 -0300 Subject: [PATCH 70/92] Update Jenkinsfile --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3786913d..9a5d2213 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -33,7 +33,6 @@ pipeline { current_stage =env.STAGE_NAME sh "echo 'Stage 2: Testing code!'" sh "./mvnw clean test -e" - sh "echo ${build_duration_msg}" end = System.currentTimeMillis() build_duration_msg = + build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } From b5dad580a974de065932c069900f8b0734725331 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 12:36:14 -0300 Subject: [PATCH 71/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9a5d2213..a99ab81b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,7 +34,7 @@ pipeline { sh "echo 'Stage 2: Testing code!'" sh "./mvnw clean test -e" end = System.currentTimeMillis() - build_duration_msg = + build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } From 1a25dc516eba2a931b9cfef1899a6d67412ffbaa Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 12:49:45 -0300 Subject: [PATCH 72/92] Update Jenkinsfile --- Jenkinsfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e29d8739..ceb4250a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -208,12 +208,12 @@ pipeline { //traer el ultimo tag del origin MY_VERSION_TAG = sh(returnStdout: true, script: 'git tag --sort=-creatordate | head -n 1').trim() if (MY_VERSION_TAG == MY_VERSION) { - // sh "git tag -d ${MY_VERSION}" + sh "git tag -d ${MY_VERSION}" sh "git push --delete origin ${MY_VERSION}" - // sh "git tag -a $MY_VERSION -m 'update release from Jenkins'" + sh "git tag -a $MY_VERSION -m 'update release from Jenkins'" sh "git push origin $MY_VERSION" } else { - // sh "git tag -a $MY_VERSION -m 'update release from Jenkins'" + sh "git tag -a $MY_VERSION -m 'update release from Jenkins'" sh "git push origin $MY_VERSION" } @@ -224,7 +224,7 @@ pipeline { sh "git push origin develop" //Release branch has been remotely deleted from 'origin' - // sh "git push origin --delete ${env.BRANCH_NAME}" + sh "git push origin --delete ${env.BRANCH_NAME}" end = System.currentTimeMillis() build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } @@ -246,4 +246,4 @@ pipeline { slackSend color: 'danger', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado:Error/Fail](<${env.BUILD_URL}|Detalle>)${build_duration_msg}", tokenCredentialId: 'id-token-slack' } } -} \ No newline at end of file +} From 87f633db0b0c4ccd8b207cc450237ca57700d4ca Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 13:04:15 -0300 Subject: [PATCH 73/92] Update Jenkinsfile --- Jenkinsfile | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ceb4250a..0f6814f0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,7 +4,7 @@ def jsonParse(def json) { new groovy.json.JsonSlurperClassic().parseText(json) } def current_stage -def build_duration_msg = "\n *Detail by stage* \n" +def build_duration_msg = "\n *Detail by Stage* \n" pipeline { agent any environment { @@ -184,7 +184,7 @@ pipeline { } } } - stage('Paso 13: Hacer merge con develop y main y aplicar tag') { + stage('Paso 13: Merge y Tag en Github') { steps { withCredentials([ gitUsernamePassword(credentialsId: 'github-jenkins', gitToolName: 'Default') @@ -240,8 +240,11 @@ pipeline { } } success{ - slackSend color: 'good', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado: Éxito/Success](<${env.BUILD_URL}|Detalle>)${build_duration_msg}", tokenCredentialId: 'id-token-slack' - } + script{ + current_stage = "Post Build" + slackSend color: 'good', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado: Éxito/Success](<${env.BUILD_URL}|Detalle>)${build_duration_msg}", tokenCredentialId: 'id-token-slack' + } + } failure{ slackSend color: 'danger', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado:Error/Fail](<${env.BUILD_URL}|Detalle>)${build_duration_msg}", tokenCredentialId: 'id-token-slack' } From dbd27b8271feb77a9e508904553fa8f490db1286 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Fri, 2 Dec 2022 13:14:58 -0300 Subject: [PATCH 74/92] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0f6814f0..ae0011b7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -242,11 +242,11 @@ pipeline { success{ script{ current_stage = "Post Build" - slackSend color: 'good', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado: Éxito/Success](<${env.BUILD_URL}|Detalle>)${build_duration_msg}", tokenCredentialId: 'id-token-slack' + slackSend color: 'good', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado: ${currentBuild.result}](<${env.BUILD_URL}|Detalle>)${build_duration_msg}", tokenCredentialId: 'id-token-slack' } } failure{ - slackSend color: 'danger', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado:Error/Fail](<${env.BUILD_URL}|Detalle>)${build_duration_msg}", tokenCredentialId: 'id-token-slack' + slackSend color: 'danger', message: "[${NOMBRE_GRUPO}] [${env.JOB_NAME}][Rama : ${env.BRANCH_NAME}] [Stage :${current_stage}][Resultado:${currentBuild.result}](<${env.BUILD_URL}|Detalle>)${build_duration_msg}", tokenCredentialId: 'id-token-slack' } } } From 99b83a87be06bac0955aae08b5e28e54980c8a61 Mon Sep 17 00:00:00 2001 From: darobles Date: Fri, 2 Dec 2022 14:52:47 -0300 Subject: [PATCH 75/92] New version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a48eea1b..010990f3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Getting Started ## Windows -test actions +V1.0.7 ======= ### Compile Code * ./mvnw.cmd clean compile -e From 6fd78c36a5d37dbe190cace2bb9b238031d1c072 Mon Sep 17 00:00:00 2001 From: Daniel Robles Date: Sat, 17 Dec 2022 16:42:15 -0300 Subject: [PATCH 76/92] funcion ValidaAPICOVID --- .devcontainer/devcontainer.json | 27 +++++++++++++++++++ .vscode/settings.json | 3 +++ .../com/devopsusach2020/model/Valida.java | 14 ++++++++++ .../com/devopsusach2020/rest/RestData.java | 26 ++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .vscode/settings.json create mode 100644 src/main/java/com/devopsusach2020/model/Valida.java diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..6cdc7d7d --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,27 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/java +{ + "name": "Java", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/java:0-17", + + "features": { + "ghcr.io/devcontainers/features/java:1": { + "version": "none", + "installMaven": "true", + "installGradle": "false" + } + } + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "java -version", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..7b016a89 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.compile.nullAnalysis.mode": "automatic" +} \ No newline at end of file diff --git a/src/main/java/com/devopsusach2020/model/Valida.java b/src/main/java/com/devopsusach2020/model/Valida.java new file mode 100644 index 00000000..bd0afb80 --- /dev/null +++ b/src/main/java/com/devopsusach2020/model/Valida.java @@ -0,0 +1,14 @@ +package com.devopsusach2020.model; + +public class Valida { + boolean statusAPI; + + public void setStatusAPI(boolean statusAPI){ + this.statusAPI = statusAPI; + } + + public boolean getStatusAPI() + { + return this.statusAPI; + } +} diff --git a/src/main/java/com/devopsusach2020/rest/RestData.java b/src/main/java/com/devopsusach2020/rest/RestData.java index 4563a9e3..b2e44753 100644 --- a/src/main/java/com/devopsusach2020/rest/RestData.java +++ b/src/main/java/com/devopsusach2020/rest/RestData.java @@ -3,6 +3,7 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -14,6 +15,7 @@ import com.devopsusach2020.model.Pais; import com.devopsusach2020.model.Mundial; +import com.devopsusach2020.model.Valida; import com.google.gson.Gson; @RestController @@ -64,4 +66,28 @@ public class RestData { response.setTotalRecovered(estado.getTotalRecovered()); return response; } + @GetMapping(path = "/checkAPI", produces = MediaType.APPLICATION_JSON_VALUE) + public @ResponseBody Valida ValidaApiCovid(){ + + LOGGER.log(Level.INFO, "Validación API COVID"); + RestTemplate restTemplate = new RestTemplate(); + Valida valida = new Valida(); + + try{ + ResponseEntity call = restTemplate.getForEntity("https://api.covid19api.com/", String.class); + HttpStatus responseCode = call.getStatusCode(); + if(responseCode.value() == 200) + { + valida.setStatusAPI(true); + } + else{ + valida.setStatusAPI(false); + } + } + catch(Exception ex){ + valida.setStatusAPI(false); + } + + return valida; + } } \ No newline at end of file From 9b23c2890e480812df28f883f486279204b3bd8f Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Sat, 17 Dec 2022 18:28:36 -0300 Subject: [PATCH 77/92] Update Jenkinsfile added support for feature branches --- Jenkinsfile | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ae0011b7..9f0e6414 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -173,6 +173,7 @@ pipeline { } } stage('Paso 12: Desplegar en Produccion') { + when { anyOf { branch 'release*' } } steps { script { start = System.currentTimeMillis() @@ -185,6 +186,7 @@ pipeline { } } stage('Paso 13: Merge y Tag en Github') { + when { anyOf { branch 'release*' } } steps { withCredentials([ gitUsernamePassword(credentialsId: 'github-jenkins', gitToolName: 'Default') @@ -192,7 +194,7 @@ pipeline { script{ start = System.currentTimeMillis() current_stage =env.STAGE_NAME - sh "echo 'Stage 13: Merging branch on main and develop and create tag'" + sh "echo 'Stage 13: Merging branch release on main and develop and create tag'" //Release branch has been merged into '$GITHUB_EMAIL' sh "git config --global user.email '$GITHUB_EMAIL'" sh "git config --global user.name '$GITHUB_USERNAME'" @@ -232,6 +234,37 @@ pipeline { } } } + stage('Paso 14: Merge con develop en Github') { + when { anyOf { branch 'feature*' } } + steps { + withCredentials([ + gitUsernamePassword(credentialsId: 'github-jenkins', gitToolName: 'Default') + ]) { + script{ + start = System.currentTimeMillis() + current_stage =env.STAGE_NAME + sh "echo 'Stage 13: Merging branch feature on develop'" + //Release branch has been merged into '$GITHUB_EMAIL' + sh "git config --global user.email '$GITHUB_EMAIL'" + sh "git config --global user.name '$GITHUB_USERNAME'" + sh "git checkout ${env.BRANCH_NAME}" + sh "git pull origin" + + //merge into develop + sh "git checkout develop" + sh "git pull origin develop" + sh "git merge ${env.BRANCH_NAME}" + sh "git push origin develop" + + //Release branch has been remotely deleted from 'origin' + //sh "git push origin --delete ${env.BRANCH_NAME}" + end = System.currentTimeMillis() + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" + } + + } + } + } } post{ always{ From 2c3d07bf86908a0d22df4c76912206b49b9220d7 Mon Sep 17 00:00:00 2001 From: Daniel Robles Date: Sat, 17 Dec 2022 18:31:36 -0300 Subject: [PATCH 78/92] new changes --- .../DevOpsUsach2020ApplicationTests.java | 4 ++- .../devopsusach2020/EstadoMundialTest.java | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/devopsusach2020/EstadoMundialTest.java diff --git a/src/test/java/com/devopsusach2020/DevOpsUsach2020ApplicationTests.java b/src/test/java/com/devopsusach2020/DevOpsUsach2020ApplicationTests.java index 0849fbe9..d1820099 100644 --- a/src/test/java/com/devopsusach2020/DevOpsUsach2020ApplicationTests.java +++ b/src/test/java/com/devopsusach2020/DevOpsUsach2020ApplicationTests.java @@ -1,10 +1,12 @@ package com.devopsusach2020; + + import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest -class DevOpsUsach2020ApplicationTests { +class DevOpsUsach2020ApplicationTests { @Test void contextLoads() { diff --git a/src/test/java/com/devopsusach2020/EstadoMundialTest.java b/src/test/java/com/devopsusach2020/EstadoMundialTest.java new file mode 100644 index 00000000..f50c98e2 --- /dev/null +++ b/src/test/java/com/devopsusach2020/EstadoMundialTest.java @@ -0,0 +1,33 @@ +package com.devopsusach2020; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +import com.devopsusach2020.rest.RestData; + +@SpringBootTest +public class EstadoMundialTest { + RestData rest = new RestData(); + + @Test + void estadoMundialTotalconfirmed() { + assertEquals(true,rest.ValidaApiCovid().getStatusAPI()); + assertTrue(rest.getTotalMundial().getTotalConfirmed() >= 0); + } + + @Test + void estadoMundialTotalDeath() { + assertEquals(true,rest.ValidaApiCovid().getStatusAPI()); + assertTrue(rest.getTotalMundial().getTotalDeaths() >= 0); + } + + @Test + void estadoMundialTotalRecovered() { + assertEquals(true,rest.ValidaApiCovid().getStatusAPI()); + assertTrue(rest.getTotalMundial().getTotalRecovered() >= 0); + } + +} \ No newline at end of file From e00de852db57a0620ce703641b7d0a4b65e03531 Mon Sep 17 00:00:00 2001 From: Daniel Robles Date: Sat, 17 Dec 2022 18:33:56 -0300 Subject: [PATCH 79/92] test estado mundial --- README.md | 2 +- src/test/java/com/devopsusach2020/EstadoMundialTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 65e45931..72d05dc4 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ======= ## Windows -V1.0.7 +V1.0.7 Estado mundial ======= ### Compile Code * ./mvnw.cmd clean compile -e diff --git a/src/test/java/com/devopsusach2020/EstadoMundialTest.java b/src/test/java/com/devopsusach2020/EstadoMundialTest.java index f50c98e2..6cbf6a9d 100644 --- a/src/test/java/com/devopsusach2020/EstadoMundialTest.java +++ b/src/test/java/com/devopsusach2020/EstadoMundialTest.java @@ -26,7 +26,7 @@ void estadoMundialTotalDeath() { @Test void estadoMundialTotalRecovered() { - assertEquals(true,rest.ValidaApiCovid().getStatusAPI()); + assertTrue(rest.getTotalMundial().getTotalRecovered() >= 0); } From 2ac9c512ae1efe02b3e3b9098baee705f760c398 Mon Sep 17 00:00:00 2001 From: Daniel Robles Date: Sat, 17 Dec 2022 18:45:12 -0300 Subject: [PATCH 80/92] corregido jenkins file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 72d05dc4..26f9bac0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ======= ## Windows -V1.0.7 Estado mundial +V1.0.7 Estado mundial2 ======= ### Compile Code * ./mvnw.cmd clean compile -e From 09bdcb78b5dfb51145d4d947cb07d129d9c402cd Mon Sep 17 00:00:00 2001 From: Daniel Robles Date: Sat, 17 Dec 2022 18:59:23 -0300 Subject: [PATCH 81/92] corregido jenkins file --- Jenkinsfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9f0e6414..f08fe5a1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,6 +14,14 @@ pipeline { NOMBRE_GRUPO = 'Grupo 7' } stages { + stage("Paso 0"){ + when { branch 'feature*' } + steps { + script { + sh "echo 'Entre con una feature'" + } + } + } stage("Paso 1: Compilar"){ steps { script { @@ -235,7 +243,7 @@ pipeline { } } stage('Paso 14: Merge con develop en Github') { - when { anyOf { branch 'feature*' } } + when { branch 'feature*' } steps { withCredentials([ gitUsernamePassword(credentialsId: 'github-jenkins', gitToolName: 'Default') From ae861d9a7d3d3ed2f44d2d818b4e8e061cc13ffb Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Sat, 17 Dec 2022 19:03:56 -0300 Subject: [PATCH 82/92] Update Jenkinsfile --- Jenkinsfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f08fe5a1..9c8133c5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -15,7 +15,11 @@ pipeline { } stages { stage("Paso 0"){ - when { branch 'feature*' } + when { + anyOf { + branch 'featu*' + } + } steps { script { sh "echo 'Entre con una feature'" From 1df28fb72f4a855c4cb10042502fc485bdb63fc2 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Sat, 17 Dec 2022 19:05:55 -0300 Subject: [PATCH 83/92] Update Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9c8133c5..c710fd1d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,7 @@ pipeline { stage("Paso 0"){ when { anyOf { - branch 'featu*' + branch 'feature/*' } } steps { From f1dc19b50bae34c36513ecfe7d29f6ce6dded210 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Sat, 17 Dec 2022 19:07:19 -0300 Subject: [PATCH 84/92] Update Jenkinsfile --- Jenkinsfile | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c710fd1d..b60a6600 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -14,18 +14,6 @@ pipeline { NOMBRE_GRUPO = 'Grupo 7' } stages { - stage("Paso 0"){ - when { - anyOf { - branch 'feature/*' - } - } - steps { - script { - sh "echo 'Entre con una feature'" - } - } - } stage("Paso 1: Compilar"){ steps { script { @@ -198,7 +186,7 @@ pipeline { } } stage('Paso 13: Merge y Tag en Github') { - when { anyOf { branch 'release*' } } + when { anyOf { branch 'release/*' } } steps { withCredentials([ gitUsernamePassword(credentialsId: 'github-jenkins', gitToolName: 'Default') @@ -247,7 +235,7 @@ pipeline { } } stage('Paso 14: Merge con develop en Github') { - when { branch 'feature*' } + when { branch 'feature/*' } steps { withCredentials([ gitUsernamePassword(credentialsId: 'github-jenkins', gitToolName: 'Default') From 8a19c46cb76ec69dcdf557f2ac4366b11b98e506 Mon Sep 17 00:00:00 2001 From: Daniel Morales Date: Sat, 17 Dec 2022 19:35:27 -0300 Subject: [PATCH 85/92] estadopais --- .../java/com/devopsusach2020/EstadoPais.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/java/com/devopsusach2020/EstadoPais.java diff --git a/src/test/java/com/devopsusach2020/EstadoPais.java b/src/test/java/com/devopsusach2020/EstadoPais.java new file mode 100644 index 00000000..67eb9539 --- /dev/null +++ b/src/test/java/com/devopsusach2020/EstadoPais.java @@ -0,0 +1,34 @@ + +package com.devopsusach2020; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +import com.devopsusach2020.rest.RestData; + +@SpringBootTest +public class EstadoPais { + RestData rest = new RestData(); + + @Test + void estadoMuertesPais() throws Exception { + + assertEquals(true,rest.ValidaApiCovid().getStatusAPI()); + assertTrue(rest.getTotalPais("Chile").getDeaths() >= 0); + } + @Test + void estadoConfirmadoPais() throws Exception { + + assertEquals(true,rest.ValidaApiCovid().getStatusAPI()); + assertTrue(rest.getTotalPais("Chile").getConfirmed() >= 0); + } + @Test + void estadoMensajePais() throws Exception { + + assertEquals(true,rest.ValidaApiCovid().getStatusAPI()); + assertEquals("ok", rest.getTotalPais("Chile").getMensaje()); + } +} \ No newline at end of file From e851df51e1bf1f03b791d73d2a4f1e8d9530e91f Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Sat, 17 Dec 2022 19:42:11 -0300 Subject: [PATCH 86/92] Update Jenkinsfile --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b60a6600..dc003be3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -68,7 +68,7 @@ pipeline { start = System.currentTimeMillis() current_stage =env.STAGE_NAME sh "echo 'Stage 5: Testing deploy!'" - sh "sleep 10" + sh "sleep 20" sh "curl -X GET 'http://localhost:8081/rest/mscovid/estadoPais?pais=Chile'" end = System.currentTimeMillis() build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" @@ -257,7 +257,7 @@ pipeline { sh "git push origin develop" //Release branch has been remotely deleted from 'origin' - //sh "git push origin --delete ${env.BRANCH_NAME}" + sh "git push origin --delete ${env.BRANCH_NAME}" end = System.currentTimeMillis() build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } From 5bd8346f632825ee34f2d7e2109905665cfa4902 Mon Sep 17 00:00:00 2001 From: Daniel Robles Date: Sun, 18 Dec 2022 18:22:41 -0300 Subject: [PATCH 87/92] added postman test for pipeline --- Jenkinsfile | 48 ++++++++++++++++---------- test_api_covid.postman_collection.json | 25 ++++++++++++++ 2 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 test_api_covid.postman_collection.json diff --git a/Jenkinsfile b/Jenkinsfile index dc003be3..4a791b03 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -75,12 +75,24 @@ pipeline { } } } - stage("Paso 6: stop Testing deploy"){ + stage("Paso 6: Running postman tests"){ steps { script { start = System.currentTimeMillis() current_stage =env.STAGE_NAME - sh "echo 'Stage 6: Stopping jar running'" + sh "echo 'Stage 6: Testing deploy!'" + sh "newman run test_api_covid.postman_collection.json" + end = System.currentTimeMillis() + build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" + } + } + } + stage("Paso 7: stop Testing deploy"){ + steps { + script { + start = System.currentTimeMillis() + current_stage =env.STAGE_NAME + sh "echo 'Stage 7: Stopping jar running'" sh "sleep 10" sh '''kill -9 $(pidof java | awk '{print $1}')''' end = System.currentTimeMillis() @@ -88,13 +100,13 @@ pipeline { } } } - stage("Paso 7: Analizar en Sonar"){ + stage("Paso 8: Analizar en Sonar"){ steps { script { start = System.currentTimeMillis() current_stage =env.STAGE_NAME withSonarQubeEnv('sonarqube') { - sh "echo 'Stage 7: Static code analysis in Sonar'" + sh "echo 'Stage 8: Static code analysis in Sonar'" sh 'sh mvnw clean verify sonar:sonar -Dsonar.projectKey=com.devopsusach2020:DevOpsUsach2020' } end = System.currentTimeMillis() @@ -102,12 +114,12 @@ pipeline { } } } - stage("Paso 8: Release Subir Artefacto a Nexus"){ + stage("Paso 9: Release Subir Artefacto a Nexus"){ steps { script { start = System.currentTimeMillis() current_stage =env.STAGE_NAME - sh "echo 'Stage 8:Uploading artifact to Nexus'" + sh "echo 'Stage 9:Uploading artifact to Nexus'" MY_VERSION = env.BRANCH_NAME.substring(8) nexusPublisher nexusInstanceId: 'maven-ceres-repository', nexusRepositoryId: 'maven-usach-ceres', @@ -132,12 +144,12 @@ pipeline { } } } - stage('Paso 9: Descargar ultima version jar de Nexus') { + stage('Paso 10: Descargar ultima version jar de Nexus') { steps { script { start = System.currentTimeMillis() current_stage =env.STAGE_NAME - sh "echo 'Stage 9:Downloading artifact from Nexus'" + sh "echo 'Stage 10:Downloading artifact from Nexus'" MY_VERSION = env.BRANCH_NAME.substring(8) MY_EXTENSION = ".jar" sh "curl -X GET 'http://nexus:8081/repository/maven-usach-ceres/com/devopsusach2020/DevOpsUsach2020/$MY_VERSION/DevOpsUsach2020-$MY_VERSION$MY_EXTENSION' -O" @@ -146,12 +158,12 @@ pipeline { } } } - stage('Paso 10: Levantar y testear Artefacto Jar obtenido de nexus') { + stage('Paso 11: Levantar y testear Artefacto Jar obtenido de nexus') { steps { script { start = System.currentTimeMillis() current_stage =env.STAGE_NAME - sh "echo 'Stage 10:Testing artifact downloaded from Nexus'" + sh "echo 'Stage 11:Testing artifact downloaded from Nexus'" sh "nohup java -jar DevOpsUsach2020-$MY_VERSION$MY_EXTENSION & >/dev/null" sh "sleep 20 && curl -X GET 'http://jenkins:8081/rest/mscovid/test?msg=testing'" end = System.currentTimeMillis() @@ -159,12 +171,12 @@ pipeline { } } } - stage('Paso 11:Detener Atefacto jar en Jenkins server') { + stage('Paso 12:Detener Atefacto jar en Jenkins server') { steps { script { start = System.currentTimeMillis() current_stage =env.STAGE_NAME - sh "echo 'Stage 11: Stopping artifact'" + sh "echo 'Stage 12: Stopping artifact'" sh "sleep 10" sh '''kill -9 $(pidof java | awk '{print $1}')''' end = System.currentTimeMillis() @@ -172,20 +184,20 @@ pipeline { } } } - stage('Paso 12: Desplegar en Produccion') { + stage('Paso 13: Desplegar en Produccion') { when { anyOf { branch 'release*' } } steps { script { start = System.currentTimeMillis() current_stage =env.STAGE_NAME - sh "echo 'Stage 12: Deploying on production'" + sh "echo 'Stage 13: Deploying on production'" sh "echo 'enviado a produccion $MY_VERSION'" end = System.currentTimeMillis() build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } } } - stage('Paso 13: Merge y Tag en Github') { + stage('Paso 14: Merge y Tag en Github') { when { anyOf { branch 'release/*' } } steps { withCredentials([ @@ -194,7 +206,7 @@ pipeline { script{ start = System.currentTimeMillis() current_stage =env.STAGE_NAME - sh "echo 'Stage 13: Merging branch release on main and develop and create tag'" + sh "echo 'Stage 14: Merging branch release on main and develop and create tag'" //Release branch has been merged into '$GITHUB_EMAIL' sh "git config --global user.email '$GITHUB_EMAIL'" sh "git config --global user.name '$GITHUB_USERNAME'" @@ -234,7 +246,7 @@ pipeline { } } } - stage('Paso 14: Merge con develop en Github') { + stage('Paso 15: Merge con develop en Github') { when { branch 'feature/*' } steps { withCredentials([ @@ -243,7 +255,7 @@ pipeline { script{ start = System.currentTimeMillis() current_stage =env.STAGE_NAME - sh "echo 'Stage 13: Merging branch feature on develop'" + sh "echo 'Stage 15: Merging branch feature on develop'" //Release branch has been merged into '$GITHUB_EMAIL' sh "git config --global user.email '$GITHUB_EMAIL'" sh "git config --global user.name '$GITHUB_USERNAME'" diff --git a/test_api_covid.postman_collection.json b/test_api_covid.postman_collection.json new file mode 100644 index 00000000..97102edc --- /dev/null +++ b/test_api_covid.postman_collection.json @@ -0,0 +1,25 @@ +{ + "info": { + "_postman_id": "cdbb70f8-a9c2-4355-a643-38947c95c602", + "name": "Test API Covid", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "estadoPais", + "request": { + "method": "GET", + "header": [] + }, + "response": [] + }, + { + "name": "estadoMundialRespuesta", + "request": { + "method": "GET", + "header": [] + }, + "response": [] + } + ] +} \ No newline at end of file From 0890052c82a17938f92d7e16201f643d00a2ce8a Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Sun, 18 Dec 2022 18:31:32 -0300 Subject: [PATCH 88/92] Add files via upload From 3150192250f5efe1ac9635459681edf27b4bd640 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Sun, 18 Dec 2022 18:32:07 -0300 Subject: [PATCH 89/92] Update test_api_covid.postman_collection.json --- test_api_covid.postman_collection.json | 130 ++++++++++++++++++++++++- 1 file changed, 127 insertions(+), 3 deletions(-) diff --git a/test_api_covid.postman_collection.json b/test_api_covid.postman_collection.json index 97102edc..e59a34e5 100644 --- a/test_api_covid.postman_collection.json +++ b/test_api_covid.postman_collection.json @@ -7,19 +7,143 @@ "item": [ { "name": "estadoPais", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const schema = {\r", + " \"type\": \"object\",\r", + " \"properties\":{\r", + " \"deaths\":{\r", + " \"type\" : \"number\"\r", + " },\r", + " \"confirmed\":{\r", + " \"type\": \"number\"\r", + " },\r", + " \"date\":{\r", + " \"type\": \"string\"\r", + " },\r", + " \"mensaje\":{\r", + " \"type\": \"string\"\r", + " },\r", + " \"country\":{\r", + " \"type\": \"string\"\r", + " },\r", + " \"recovered\":{\r", + " \"type\": \"number\"\r", + " },\r", + " \"active\":{\r", + " \"type\": \"number\"\r", + " }\r", + " }, \r", + " \"required\": [\r", + " \"deaths\",\r", + " \"confirmed\",\r", + " \"date\",\r", + " \"mensaje\",\r", + " \"country\",\r", + " \"recovered\",\r", + " \"active\"\r", + " ]\r", + "};\r", + "pm.test(\"Status code is 200\", function () {\r", + " pm.expect(pm.response).to.have.status(200);\r", + "});\r", + "pm.test(\"Mensaje == ok\", function () {\r", + " pm.expect(pm.response.responseTime).to.be.below(5000);\r", + "});\r", + "pm.test('Schema is valid', function() {\r", + " pm.response.to.have.jsonSchema(schema);\r", + "});" + ], + "type": "text/javascript" + } + } + ], "request": { "method": "GET", - "header": [] + "header": [], + "url": { + "raw": "http://localhost:8081/rest/mscovid/estadoPais?pais=ecuador", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8081", + "path": [ + "rest", + "mscovid", + "estadoPais" + ], + "query": [ + { + "key": "pais", + "value": "ecuador" + } + ] + } }, "response": [] }, { "name": "estadoMundialRespuesta", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "const schema = {\r", + " \"type\": \"object\",\r", + " \"properties\":{\r", + " \"totalRecovered\":{\r", + " \"type\" : \"number\"\r", + " },\r", + " \"totalConfirmed\":{\r", + " \"type\": \"number\"\r", + " },\r", + " \"totalDeaths\":{\r", + " \"type\": \"number\"\r", + " }\r", + " },\r", + " \"required\": [\r", + " \"totalRecovered\",\r", + " \"totalConfirmed\",\r", + " \"totalDeaths\"\r", + " ] \r", + "};\r", + "pm.test(\"Status code is 200\", function () {\r", + " pm.expect(pm.response).to.have.status(200);\r", + "});\r", + "pm.test(\"Mensaje == ok\", function () {\r", + " pm.expect(pm.response.responseTime).to.be.below(2000);\r", + "});\r", + "pm.test('Schema is valid', function() {\r", + " pm.response.to.have.jsonSchema(schema);\r", + "});" + ], + "type": "text/javascript" + } + } + ], "request": { "method": "GET", - "header": [] + "header": [], + "url": { + "raw": "http://localhost:8081/rest/mscovid/estadoMundial", + "protocol": "http", + "host": [ + "localhost" + ], + "port": "8081", + "path": [ + "rest", + "mscovid", + "estadoMundial" + ] + } }, "response": [] } ] -} \ No newline at end of file +} From 07129992559f89ad8b1a7285c20d983afa457456 Mon Sep 17 00:00:00 2001 From: darobles <50927329+darobles@users.noreply.github.com> Date: Sun, 18 Dec 2022 18:37:16 -0300 Subject: [PATCH 90/92] Update test_api_covid.postman_collection.json --- test_api_covid.postman_collection.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_api_covid.postman_collection.json b/test_api_covid.postman_collection.json index e59a34e5..f5ad0879 100644 --- a/test_api_covid.postman_collection.json +++ b/test_api_covid.postman_collection.json @@ -51,7 +51,7 @@ " pm.expect(pm.response).to.have.status(200);\r", "});\r", "pm.test(\"Mensaje == ok\", function () {\r", - " pm.expect(pm.response.responseTime).to.be.below(5000);\r", + " pm.expect(pm.response.responseTime).to.be.below(15000);\r", "});\r", "pm.test('Schema is valid', function() {\r", " pm.response.to.have.jsonSchema(schema);\r", @@ -116,7 +116,7 @@ " pm.expect(pm.response).to.have.status(200);\r", "});\r", "pm.test(\"Mensaje == ok\", function () {\r", - " pm.expect(pm.response.responseTime).to.be.below(2000);\r", + " pm.expect(pm.response.responseTime).to.be.below(3000);\r", "});\r", "pm.test('Schema is valid', function() {\r", " pm.response.to.have.jsonSchema(schema);\r", From 26a76751df08d54960511538e9eee0b5554decaf Mon Sep 17 00:00:00 2001 From: Daniel Robles Date: Sun, 18 Dec 2022 18:47:50 -0300 Subject: [PATCH 91/92] fixed test postman --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 26f9bac0..5482b6d7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ======= ## Windows -V1.0.7 Estado mundial2 +V1.0.9 test postman ======= ### Compile Code * ./mvnw.cmd clean compile -e From f61c8202030c2407fb3199a19f06adb334641db0 Mon Sep 17 00:00:00 2001 From: Daniel Robles Date: Sun, 18 Dec 2022 19:11:51 -0300 Subject: [PATCH 92/92] added curl to methods --- Jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4a791b03..6b5b321a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -165,7 +165,8 @@ pipeline { current_stage =env.STAGE_NAME sh "echo 'Stage 11:Testing artifact downloaded from Nexus'" sh "nohup java -jar DevOpsUsach2020-$MY_VERSION$MY_EXTENSION & >/dev/null" - sh "sleep 20 && curl -X GET 'http://jenkins:8081/rest/mscovid/test?msg=testing'" + sh "sleep 20 && curl -X GET 'http://jenkins:8081/rest/mscovid/estadoPais?pais=ecuador'" + sh "sleep 20 && curl -X GET 'http://jenkins:8081/rest/mscovid/estadoMundial'" end = System.currentTimeMillis() build_duration_msg = build_duration_msg + "*" + current_stage + "*" + " : " + Util.getTimeSpanString(end - start) +"\n" } @@ -185,7 +186,7 @@ pipeline { } } stage('Paso 13: Desplegar en Produccion') { - when { anyOf { branch 'release*' } } + when { anyOf { branch 'release/*' } } steps { script { start = System.currentTimeMillis()