From 1b654b85fb65a3d759d133a2f86fe30d7d11607c Mon Sep 17 00:00:00 2001 From: Mark Davydov Date: Sat, 9 Feb 2019 23:37:46 +0200 Subject: [PATCH 01/14] Added a failing test , for the reports on Jenkins. --- .../com/example/javamavenjunithelloworld/Hello.java | 2 +- .../example/javamavenjunithelloworld/HelloTest.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/example/javamavenjunithelloworld/Hello.java b/src/main/java/com/example/javamavenjunithelloworld/Hello.java index 7338993b..96e82a96 100644 --- a/src/main/java/com/example/javamavenjunithelloworld/Hello.java +++ b/src/main/java/com/example/javamavenjunithelloworld/Hello.java @@ -8,7 +8,7 @@ public class Hello { static final String HELLO = "Hello!"; - + static final String BAD_HELLO = "No Hello!"; public static final int MAXIMUM_AMOUNT_OF_TIMES = 20; private int times = 1; diff --git a/src/test/java/com/example/javamavenjunithelloworld/HelloTest.java b/src/test/java/com/example/javamavenjunithelloworld/HelloTest.java index 7bfd1f0b..474ce7b2 100644 --- a/src/test/java/com/example/javamavenjunithelloworld/HelloTest.java +++ b/src/test/java/com/example/javamavenjunithelloworld/HelloTest.java @@ -31,6 +31,17 @@ public void testSayHello() { assertThat(os.toString(), is(equalTo(String.format("%s%s", Hello.HELLO, System.lineSeparator())))); } + + @Test + public void testSayHelloFail() { + OutputStream os = new ByteArrayOutputStream(); + PrintStream stream = new PrintStream(os, true); + + Hello hi = new Hello(); + hi.sayHello(stream); + + assertThat(os.toString(), is(equalTo(String.format("%s%s", Hello.BAD_HELLO, System.lineSeparator())))); + } @Test public void testSayHelloAFewTimes() { From 3aceacc549cf757fcdb1c164209bad4eb8525e86 Mon Sep 17 00:00:00 2001 From: Mark Davydov Date: Sat, 2 Mar 2019 23:05:59 +0200 Subject: [PATCH 02/14] Create Jenkinsfile.pipeline Added jenkinsfile. --- Jenkinsfile.pipeline | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Jenkinsfile.pipeline diff --git a/Jenkinsfile.pipeline b/Jenkinsfile.pipeline new file mode 100644 index 00000000..415e53f2 --- /dev/null +++ b/Jenkinsfile.pipeline @@ -0,0 +1,32 @@ +pipeline { + agent { docker { image 'maven:3.6.0-jdk-8-alpine' } } + stages { + stage('Git') { + // Get some code from a GitHub repository + steps{ + git 'https://github.com/markrity/java-maven-junit-helloworld.git' + } + } + stage('Build'){ + steps{ + sh "mvn -Dmaven.test.skip=true clean package" + } + } + stage('Unit Test'){ + steps{ + sh "mvn -Dmaven.test.failure.ignore clean test" + } + } + stage('Integrational Test'){ + steps{ + sh "mvn -Dmaven.test.failure.ignore clean install" + } + } + stage('Results') { + steps{ + junit '**/target/surefire-reports/TEST-*.xml' + step( [ $class: 'JacocoPublisher' ] ) + } + } +} +} From 9a310d120518d38da8f483b7a351f1599ec4db67 Mon Sep 17 00:00:00 2001 From: Mark Davydov Date: Sat, 16 Mar 2019 23:33:36 +0200 Subject: [PATCH 03/14] Update Jenkinsfile.pipeline update to scm --- Jenkinsfile.pipeline | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile.pipeline b/Jenkinsfile.pipeline index 415e53f2..9599d64a 100644 --- a/Jenkinsfile.pipeline +++ b/Jenkinsfile.pipeline @@ -4,7 +4,7 @@ pipeline { stage('Git') { // Get some code from a GitHub repository steps{ - git 'https://github.com/markrity/java-maven-junit-helloworld.git' + checkout scm } } stage('Build'){ From cdcaa9342d055abb2953e49b7f47f5dc1688e7d6 Mon Sep 17 00:00:00 2001 From: Mark Davydov Date: Sat, 16 Mar 2019 23:35:55 +0200 Subject: [PATCH 04/14] Update Jenkinsfile.pipeline --- Jenkinsfile.pipeline | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile.pipeline b/Jenkinsfile.pipeline index 9599d64a..138205dd 100644 --- a/Jenkinsfile.pipeline +++ b/Jenkinsfile.pipeline @@ -23,6 +23,7 @@ pipeline { } } stage('Results') { + //Publish results steps{ junit '**/target/surefire-reports/TEST-*.xml' step( [ $class: 'JacocoPublisher' ] ) From 68204521089e61c58ca674091882fe209861ca7a Mon Sep 17 00:00:00 2001 From: Mark Davydov Date: Sun, 17 Mar 2019 12:34:37 +0200 Subject: [PATCH 05/14] Update Jenkinsfile.pipeline Added comment. --- Jenkinsfile.pipeline | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile.pipeline b/Jenkinsfile.pipeline index 138205dd..d3aeadf8 100644 --- a/Jenkinsfile.pipeline +++ b/Jenkinsfile.pipeline @@ -29,5 +29,6 @@ pipeline { step( [ $class: 'JacocoPublisher' ] ) } } + //fun comment. } } From 6158598462a5d842ccf8c1ccdcded7ccf7558f85 Mon Sep 17 00:00:00 2001 From: Mark Davydov Date: Sun, 17 Mar 2019 14:31:26 +0200 Subject: [PATCH 06/14] Update Jenkinsfile.pipeline Demo --- Jenkinsfile.pipeline | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile.pipeline b/Jenkinsfile.pipeline index d3aeadf8..a077252f 100644 --- a/Jenkinsfile.pipeline +++ b/Jenkinsfile.pipeline @@ -1,3 +1,4 @@ +//Just for demo. pipeline { agent { docker { image 'maven:3.6.0-jdk-8-alpine' } } stages { From fcf82ede91f8beae5e45ea8a29bdfa4374dbb72b Mon Sep 17 00:00:00 2001 From: Mark Davydov Date: Sun, 8 Sep 2019 09:55:31 +0300 Subject: [PATCH 07/14] Testing GitHub Actions --- .github/workflows/maven.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/maven.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 00000000..7929f143 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,17 @@ +name: Java CI + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build with Maven + run: mvn -Dmaven.test.failure.ignore clean test From 843141978b8ead277dc22a0f32cab9c559cafe36 Mon Sep 17 00:00:00 2001 From: Mark Davydov Date: Fri, 13 Sep 2019 19:12:53 +0300 Subject: [PATCH 08/14] Set up CI with Azure Pipelines [skip ci] --- azure-pipelines.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 azure-pipelines.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml new file mode 100644 index 00000000..03897a82 --- /dev/null +++ b/azure-pipelines.yml @@ -0,0 +1,22 @@ +# Maven +# Build your Java project and run tests with Apache Maven. +# Add steps that analyze code, save build artifacts, deploy, and more: +# https://docs.microsoft.com/azure/devops/pipelines/languages/java + +trigger: +- master + +pool: + vmImage: 'ubuntu-latest' + +steps: +- task: Maven@3 + inputs: + mavenPomFile: 'pom.xml' + mavenOptions: '-Xmx3072m' + javaHomeOption: 'JDKVersion' + jdkVersionOption: '1.8' + jdkArchitectureOption: 'x64' + publishJUnitResults: true + testResultsFiles: '**/surefire-reports/TEST-*.xml' + goals: 'package' From 3b9ece61e67a0c8e96b18adab98275037439547c Mon Sep 17 00:00:00 2001 From: Mark Davydov Date: Fri, 13 Sep 2019 19:26:13 +0300 Subject: [PATCH 09/14] Added CodeCoverage --- azure-pipelines.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 03897a82..d36e2514 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -20,3 +20,12 @@ steps: publishJUnitResults: true testResultsFiles: '**/surefire-reports/TEST-*.xml' goals: 'package' + +- task: PublishCodeCoverageResults@1 + inputs: + codeCoverageTool: 'JaCoCo' # Options: cobertura, jaCoCo + summaryFileLocation: + #pathToSources: # Optional + #reportDirectory: # Optional + #additionalCodeCoverageFiles: # Optional + #failIfCoverageEmpty: false # Optional From 71c8c78a824d393d33fe7a1e28ca1285d3c6a558 Mon Sep 17 00:00:00 2001 From: Mark Davydov Date: Fri, 13 Sep 2019 19:28:28 +0300 Subject: [PATCH 10/14] Added maven test failure ignore --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d36e2514..eed19df3 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,7 +13,7 @@ steps: - task: Maven@3 inputs: mavenPomFile: 'pom.xml' - mavenOptions: '-Xmx3072m' + mavenOptions: '-Xmx3072m -Dmaven.test.failure.ignore' javaHomeOption: 'JDKVersion' jdkVersionOption: '1.8' jdkArchitectureOption: 'x64' From daa946a7e80c0a2305f43dd968e53da6861ae0e6 Mon Sep 17 00:00:00 2001 From: Mark Davydov Date: Fri, 13 Sep 2019 19:31:44 +0300 Subject: [PATCH 11/14] Set maven Options --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index eed19df3..231c33d1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,7 +13,7 @@ steps: - task: Maven@3 inputs: mavenPomFile: 'pom.xml' - mavenOptions: '-Xmx3072m -Dmaven.test.failure.ignore' + mavenOptions: '-Xmx3072m','-Dmaven.test.failure.ignore' javaHomeOption: 'JDKVersion' jdkVersionOption: '1.8' jdkArchitectureOption: 'x64' From 36ba7973653a6803de869e217710d79b1180b0ba Mon Sep 17 00:00:00 2001 From: Mark Davydov Date: Fri, 13 Sep 2019 20:40:57 +0300 Subject: [PATCH 12/14] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 231c33d1..da674f95 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -13,19 +13,24 @@ steps: - task: Maven@3 inputs: mavenPomFile: 'pom.xml' - mavenOptions: '-Xmx3072m','-Dmaven.test.failure.ignore' + mavenOptions: '-Xmx3072m','- task: Maven@3 + inputs: + mavenPomFile: 'pom.xml' + options: '-Dmaven.test.failure.ignore' + publishJUnitResults: true + testResultsFiles: '**/surefire-reports/TEST-*.xml' + codeCoverageToolOption: 'JaCoCo' + javaHomeOption: 'JDKVersion' + jdkVersionOption: '1.8' + mavenVersionOption: 'Default' + mavenAuthenticateFeed: false + effectivePomSkip: false + sonarQubeRunAnalysis: false + checkStyleRunAnalysis: true + findBugsRunAnalysis: true' javaHomeOption: 'JDKVersion' jdkVersionOption: '1.8' jdkArchitectureOption: 'x64' publishJUnitResults: true testResultsFiles: '**/surefire-reports/TEST-*.xml' - goals: 'package' - -- task: PublishCodeCoverageResults@1 - inputs: - codeCoverageTool: 'JaCoCo' # Options: cobertura, jaCoCo - summaryFileLocation: - #pathToSources: # Optional - #reportDirectory: # Optional - #additionalCodeCoverageFiles: # Optional - #failIfCoverageEmpty: false # Optional + goals: 'package' \ No newline at end of file From 8da25eeb7f3973ca5f199a7762e8fb2e0b811a9b Mon Sep 17 00:00:00 2001 From: Mark Davydov Date: Fri, 13 Sep 2019 20:41:10 +0300 Subject: [PATCH 13/14] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index da674f95..de5a26d1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -11,9 +11,6 @@ pool: steps: - task: Maven@3 - inputs: - mavenPomFile: 'pom.xml' - mavenOptions: '-Xmx3072m','- task: Maven@3 inputs: mavenPomFile: 'pom.xml' options: '-Dmaven.test.failure.ignore' From 1be61b6454fc0b4459bf53b7a186c5b60e2e7fe9 Mon Sep 17 00:00:00 2001 From: Mark Davydov Date: Fri, 13 Sep 2019 20:43:12 +0300 Subject: [PATCH 14/14] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index de5a26d1..a2a75980 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -24,10 +24,4 @@ steps: effectivePomSkip: false sonarQubeRunAnalysis: false checkStyleRunAnalysis: true - findBugsRunAnalysis: true' - javaHomeOption: 'JDKVersion' - jdkVersionOption: '1.8' - jdkArchitectureOption: 'x64' - publishJUnitResults: true - testResultsFiles: '**/surefire-reports/TEST-*.xml' - goals: 'package' \ No newline at end of file + findBugsRunAnalysis: true \ No newline at end of file