From bacd243df08c21676b23d9797a4a4617407449ec Mon Sep 17 00:00:00 2001 From: Marcelo de Bittencourt Date: Thu, 7 Oct 2021 19:05:25 -0300 Subject: [PATCH] Add Jenkins CI CD script --- pipeline_as_code/Jenkinsfile | 32 ++++++++++++++++++++++++++++++++ readme.md | 6 +++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 pipeline_as_code/Jenkinsfile diff --git a/pipeline_as_code/Jenkinsfile b/pipeline_as_code/Jenkinsfile new file mode 100644 index 0000000..64daf90 --- /dev/null +++ b/pipeline_as_code/Jenkinsfile @@ -0,0 +1,32 @@ +pipeline { + agent any + + tools { + // Install the Maven version configured as "M3" and add it to the path. + maven "M3" + } + + stages { + stage('Build') { + steps { + // Get some code from a GitHub repository + git 'https://github.com/marcelodebittencourt/Java_JUnit5_Unit_Test_handsOn_ViradaDaQualidade.git' + + // Run Maven on a Unix agent. + //sh "mvn -Dmaven.test.failure.ignore=true clean package" + + // To run Maven on a Windows agent, use + bat "mvn -Dmaven.test.failure.ignore=true clean package" + } + + post { + // If Maven was able to run the tests, even if some of the test + // failed, record the test results and archive the jar file. + success { + junit '**/target/surefire-reports/TEST-*.xml' + archiveArtifacts 'target/*.jar' + } + } + } + } +} \ No newline at end of file diff --git a/readme.md b/readme.md index 90efb16..017f879 100644 --- a/readme.md +++ b/readme.md @@ -75,4 +75,8 @@ Este código foi gerado ao longo do hands-on que foi realizado ao vivo no evento 7. No menu de contexto que aparece selecione "Open In" > "Browser" > "Chrome". ## Contato do autor -https://marcelodebittencourt.com \ No newline at end of file +https://marcelodebittencourt.com + +## CI/CD suportados: +* [GitHub Action](https://github.com/marcelodebittencourt/Java_JUnit5_Unit_Test_handsOn_ViradaDaQualidade/blob/master/.github/workflows/test.yml): quando um push é realizado neste repositório do GitHub, os testes são automaticamente executados. +* [Jenkins](https://github.com/marcelodebittencourt/Java_JUnit5_Unit_Test_handsOn_ViradaDaQualidade/blob/master/pipeline_as_code/Jenkinsfile): previamente configure na instância do Jenkins o apontamento para o Java JDK 11 e para o Maven coloque o nome de "M3". \ No newline at end of file