diff --git a/Jenkinsfile b/Jenkinsfile index 5e40034b58..23acf3ebf8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,45 +2,48 @@ pipeline { agent { kubernetes { label 'maven-alpine-pod' - yamlFile 'mvn-pod.yaml' + podRetention always() + idleMinutes 120 + yamlFile 'mvn-pod.yaml' } } stages { - stage ('Build') { + stage ('Build and Analysis') { steps { container ('maven') { - sh 'mvn -B -DskipTests clean package' + sh 'mvn -V -q -e clean verify -Dmaven.test.failure.ignore' } } - } - stage ('Test') { - steps { - container ('maven') { - sh 'mvn test' - } - } post { always { - junit 'target/surefire-reports/*.xml' + jacoco() + 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('Analysis') { + stage ('Test') { steps { - container ('maven') { - sh "mvn --batch-mode -V -U -e checkstyle:checkstyle pmd:pmd pmd:cpd findbugs:findbugs" - } + container ('maven') { + sh 'mvn -q test' + } } 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') + junit 'target/surefire-reports/*.xml' } } } stage ('Deliver') { + when { + beforeAgent true + branch 'master' + } steps { container ('maven') { sh './jenkins/scripts/deliver.sh' diff --git a/mvn-pod.yaml b/mvn-pod.yaml index 2004c8d9b4..fbe9dc68bf 100644 --- a/mvn-pod.yaml +++ b/mvn-pod.yaml @@ -2,6 +2,8 @@ kind: Pod metadata: name: maven-alpine-pod spec: + securityContext: + runAsUser: 1000 containers: - name: maven image: maven:3-alpine diff --git a/pom.xml b/pom.xml index 19ee4305a8..55afd71b41 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,71 @@ + + org.apache.maven.plugins + maven-pmd-plugin + 3.13.0 + + + + check + cpd-check + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.1.1 + + google_checks.xml + UTF-8 + true + true + false + + + + validate + validate + + check + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.1 + + + + prepare-agent + + + + report + package + + report + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.1.1 + + google_checks.xml + + + + diff --git a/src/main/java/com/mycompany/app/App.java b/src/main/java/com/mycompany/app/App.java index 5a6d57214d..558607566f 100644 --- a/src/main/java/com/mycompany/app/App.java +++ b/src/main/java/com/mycompany/app/App.java @@ -1,9 +1,9 @@ package com.mycompany.app; /** - * Hello world! + * Hello world app. */ -public class App +public class App { private final String message = "Hello World!";