diff --git a/Jenkinsfile b/Jenkinsfile index 018d236..0c5348f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,41 @@ -#!groovy -mavenProject { - org = 'beedemo' - repo = 'todo-api' - jdk = '8' +pipeline { + agent { + kubernetes { + label 'maven-alpine-pod' + yamlFile 'mvn-pod.yaml' + } + } + stages { + stage ('Build and Analysis') { + steps { + container ('maven') { + 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')] + } + } + } + stage ('Test') { + steps { + container ('maven') { + sh 'mvn test' + } + } + post { + always { + junit 'target/surefire-reports/*.xml' + } + } + } + } } 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 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/";