Improved Jenkinsfile: simplified maven command.
@@ -4,42 +4,34 @@ node {
}
stage ('Build') {
- def mvnHome = tool 'mvn-default'
-
- sh "${mvnHome}/bin/mvn --batch-mode -V -U -e clean verify -Dsurefire.useFile=false"
-
- junit testResults: '**/target/*-reports/TEST-*.xml'
-
- def java = scanForIssues tool: [$class: 'Java']
- def javadoc = scanForIssues tool: [$class: 'JavaDoc']
+ withMaven(maven: 'mvn-default', mavenLocalRepo: '/var/data/m2repository', mavenOpts: '-Xmx768m -Xms512m') {
+ sh 'mvn -V -U -e clean verify -DskipTests'
+ }
- publishIssues issues:[java, javadoc], filters: [includePackage('io.jenkins.plugins.analysis.*')]
+ recordIssues tools: [java(), javaDoc()], aggregatingResults: 'true', id: 'java', name: 'Java'
}
stage ('Analysis') {
- def mvnHome = tool 'mvn-default'
-
- sh "${mvnHome}/bin/mvn -batch-mode -V -U -e checkstyle:checkstyle pmd:pmd pmd:cpd findbugs:findbugs spotbugs:spotbugs"
-
- def checkstyle = scanForIssues tool: [$class: 'CheckStyle'], pattern: '**/target/checkstyle-result.xml'
- publishIssues issues:[checkstyle]
-
- def pmd = scanForIssues tool: [$class: 'Pmd'], pattern: '**/target/pmd.xml'
- publishIssues issues:[pmd]
-
- def cpd = scanForIssues tool: [$class: 'Cpd'], pattern: '**/target/cpd.xml'
- publishIssues issues:[cpd]
-
- def findbugs = scanForIssues tool: [$class: 'FindBugs'], pattern: '**/target/findbugsXml.xml'
- publishIssues issues:[findbugs]
-
- def spotbugs = scanForIssues tool: [$class: 'SpotBugs'], pattern: '**/target/spotbugsXml.xml'
- publishIssues issues:[spotbugs]
+ withMaven(maven: 'mvn-default', mavenLocalRepo: '/var/data/m2repository', mavenOpts: '-Xmx768m -Xms512m') {
+ sh "mvn -V -U -e verify"
+ }
- def maven = scanForIssues tool: [$class: 'MavenConsole']
- publishIssues issues:[maven]
+ junit testResults: '**/target/*-reports/TEST-*.xml'
+ recordIssues tools: [checkStyle(),
+ spotBugs(pattern: 'target/spotbugsXml.xml'),
+ pmdParser(pattern: 'target/pmd.xml'),
+ cpd(pattern: 'target/cpd.xml'),
+ taskScanner(highTags:'FIXME', normalTags:'TODO', includePattern: '**/*.java', excludePattern: 'target/**/*')]
+ }
- publishIssues id:'analysis', name:'White Mountains', issues:[checkstyle, pmd, findbugs, spotbugs], filters: [includePackage('io.jenkins.plugins.analysis.*')]
+ stage ('Coverage') {
+ withMaven(maven: 'mvn-default', mavenLocalRepo: '/var/data/m2repository', mavenOpts: '-Xmx768m -Xms512m') {
+ sh "mvn -V -U -e jacoco:prepare-agent test jacoco:report -Djenkins.test.timeout=240"
}
+ publishCoverage adapters: [jacocoAdapter('target/site/jacoco/jacoco.xml')]
}
+ stage ('Collect Maven Warnings') {
+ recordIssues tool: mavenConsole()
+ }
+}
\ No newline at end of file
