jenkins: only enter some stages when suitable files exist

This commit is contained in:
Paul Campbell 2018-03-09 17:30:59 +00:00
parent a377a3b508
commit 1cc7246d85

View file

@ -20,6 +20,7 @@ pipeline {
}
}
stage('Static Code Analysis') {
when { expression { findFiles(glob: '**/src/main/java/*.java').length > 0 } }
steps {
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
sh "${mvn} compile checkstyle:checkstyle pmd:pmd"
@ -46,6 +47,7 @@ pipeline {
}
}
stage('Test Results') {
when { expression { findFiles(glob: '**/target/surefire-reports/*.xml').length > 0 } }
steps {
junit '**/target/surefire-reports/*.xml'
jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class'
@ -59,6 +61,7 @@ pipeline {
}
}
stage('Archiving') {
when { expression { findFiles(glob: '**/target/*.jar').length > 0 } }
steps {
archiveArtifacts '**/target/*.jar'
}