From e4e0d429224a47bbaac7efa6752f5e321711cbaf Mon Sep 17 00:00:00 2001 From: Beedemo Developer <36600505+beedemo-dev@users.noreply.github.com> Date: Sat, 15 Aug 2020 17:18:08 -0400 Subject: [PATCH 1/4] Update Jenkinsfile --- Jenkinsfile | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 018d236..59aa787 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,44 @@ -#!groovy -mavenProject { - org = 'beedemo' - repo = 'todo-api' - jdk = '8' +pipeline { + agent { + kubernetes { + label 'maven-alpine-pod' + yamlFile 'mvn-pod.yaml' + } + } + stages { + stage ('Build') { + steps { + container ('maven') { + sh 'mvn -B -DskipTests clean package' + } + } + } + stage ('Test') { + steps { + container ('maven') { + sh 'mvn test' + } + } + post { + always { + junit 'target/surefire-reports/*.xml' + } + } + } + stage('Analysis') { + steps { + container ('maven') { + sh "mvn --batch-mode -V -U -e checkstyle:checkstyle pmd:pmd pmd:cpd findbugs:findbugs" + } + } + post { + always { + recordIssues enabledForFailure: true, tools: [mavenConsole(), java(), javaDoc()] + recordIssues enabledForFailure: true, tool: checkStyle() + recordIssues enabledForFailure: true, tool: cpd(pattern: '**/target/cpd.xml') + recordIssues enabledForFailure: true, tool: pmdParser(pattern: '**/target/pmd.xml') + } + } + } + } } From 2ac81263525e4bb0fdd276c754bdd32fee1df545 Mon Sep 17 00:00:00 2001 From: Beedemo Developer <36600505+beedemo-dev@users.noreply.github.com> Date: Sat, 15 Aug 2020 17:20:17 -0400 Subject: [PATCH 2/4] Update Jenkinsfile --- Jenkinsfile | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 59aa787..0c5348f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,10 +6,22 @@ pipeline { } } stages { - stage ('Build') { + stage ('Build and Analysis') { steps { container ('maven') { - sh 'mvn -B -DskipTests clean package' + sh 'mvn -V -e clean verify -Dmaven.test.failure.ignore' + } + } + post { + always { + publishCoverage adapters: [jacoco(path: '**/*/jacoco.xml', thresholds: [[failUnhealthy: true, thresholdTarget: 'Line', unhealthyThreshold: 60.0]])], sourceFileResolver: sourceFiles('NEVER_STORE') + recordIssues enabledForFailure: true, tools: [java(), javaDoc()], aggregatingResults: 'true', id: 'java', name: 'Java' + recordIssues enabledForFailure: true, tool: errorProne(), healthy: 1, unhealthy: 20 + recordIssues enabledForFailure: true, tools: [pmdParser(pattern: 'target/pmd.xml'), + spotBugs(pattern: 'target/spotbugsXml.xml')], + qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]] + recordIssues enabledForFailure: true, tools: [checkStyle(pattern: 'target/checkstyle-result.xml'), + cpd(pattern: 'target/cpd.xml')] } } } @@ -25,20 +37,5 @@ pipeline { } } } - stage('Analysis') { - steps { - container ('maven') { - sh "mvn --batch-mode -V -U -e checkstyle:checkstyle pmd:pmd pmd:cpd findbugs:findbugs" - } - } - post { - always { - recordIssues enabledForFailure: true, tools: [mavenConsole(), java(), javaDoc()] - recordIssues enabledForFailure: true, tool: checkStyle() - recordIssues enabledForFailure: true, tool: cpd(pattern: '**/target/cpd.xml') - recordIssues enabledForFailure: true, tool: pmdParser(pattern: '**/target/pmd.xml') - } - } - } } } From a2150d73e1c3a6656d8694cb67e7af8d96dd6b8d Mon Sep 17 00:00:00 2001 From: Beedemo Developer <36600505+beedemo-dev@users.noreply.github.com> Date: Sat, 15 Aug 2020 17:21:29 -0400 Subject: [PATCH 3/4] Create mvn-pod.yaml --- mvn-pod.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 mvn-pod.yaml diff --git a/mvn-pod.yaml b/mvn-pod.yaml new file mode 100644 index 0000000..2004c8d --- /dev/null +++ b/mvn-pod.yaml @@ -0,0 +1,10 @@ +kind: Pod +metadata: + name: maven-alpine-pod +spec: + containers: + - name: maven + image: maven:3-alpine + command: + - cat + tty: true From 3fcb6d3c38f77959a5f664dd558dbd634e46d1ae Mon Sep 17 00:00:00 2001 From: Beedemo Developer <36600505+beedemo-dev@users.noreply.github.com> Date: Wed, 19 Aug 2020 07:46:18 -0400 Subject: [PATCH 4/4] Update Main.java --- src/main/java/com/cloudbees/examples/todo/api/Main.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/cloudbees/examples/todo/api/Main.java b/src/main/java/com/cloudbees/examples/todo/api/Main.java index 9f48195..f742080 100644 --- a/src/main/java/com/cloudbees/examples/todo/api/Main.java +++ b/src/main/java/com/cloudbees/examples/todo/api/Main.java @@ -14,7 +14,8 @@ * Main class. * */ -public class Main { +public class Main +{ // Base URI the Grizzly HTTP server will listen on public static final String BASE_URI = "http://localhost:8181/";