From 1cc7246d85e2f547112d538873d87c701594827d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 9 Mar 2018 17:30:59 +0000 Subject: [PATCH] jenkins: only enter some stages when suitable files exist --- Jenkinsfile.groovy | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 02c109f..8516706 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -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' }