Improved Jenkinsfile: added tests and use maven pipeline plugin.
node {
- def mvnHome = tool 'mvn-default'
-
stage ('Checkout') {
- checkout scm
+ git branch:'master', url: 'https://github.com/jenkinsci/analysis-model.git'
}
stage ('Build') {
- sh "${mvnHome}/bin/mvn --batch-mode -V -U -e clean verify -DskipTests"
+ withMaven(maven: 'mvn-default', mavenLocalRepo: '/var/data/m2repository', mavenOpts: '-Xmx768m -Xms512m') {
+ sh 'mvn clean install --batch-mode -V -U -e clean verify -DskipTests'
+ }
recordIssues tools: [java(), javaDoc()], aggregatingResults: 'true', id: 'java', name: 'Java'
recordIssues tool: errorProne()
}
stage ('Analysis') {
- sh "${mvnHome}/bin/mvn --batch-mode -V -U -e verify"
+ withMaven(maven: 'mvn-default', mavenLocalRepo: '/var/data/m2repository', mavenOpts: '-Xmx2048m -Xms512m -XX:PermSize=256m') {
+ sh "mvn --batch-mode -V -U -e verify"
+ }
+ junit testResults: '**/target/*-reports/TEST-*.xml'
recordIssues tools: [checkStyle(),
spotBugs(pattern: 'target/spotbugsXml.xml'),
pmdParser(pattern: 'target/pmd.xml'),
@@ -23,7 +26,9 @@ node {
}
stage ('Coverage') {
- sh "${mvnHome}/bin/mvn --batch-mode -V -U -e jacoco:prepare-agent test jacoco:report -Djenkins.test.timeout=240"
+ withMaven(maven: 'mvn-default', mavenLocalRepo: '/var/data/m2repository', mavenOpts: '-Xmx2048m -Xms512m -XX:PermSize=256m') {
+ sh "mvn --batch-mode -V -U -e jacoco:prepare-agent test jacoco:report -Djenkins.test.timeout=240"
+ }
publishCoverage adapters: [jacocoAdapter('target/site/jacoco/jacoco.xml')]
}
