jenkins: Don't build java in parallel and only enter stages when suitable files found
This commit is contained in:
parent
fd78eeece6
commit
02ab4eaada
1 changed files with 15 additions and 15 deletions
|
@ -13,13 +13,15 @@ pipeline {
|
||||||
when {
|
when {
|
||||||
expression {
|
expression {
|
||||||
(env.GIT_BRANCH == 'master' || env.CHANGE_TARGET == 'master') &&
|
(env.GIT_BRANCH == 'master' || env.CHANGE_TARGET == 'master') &&
|
||||||
(readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT") }
|
(readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
error("Build failed because SNAPSHOT version")
|
error("Build failed because SNAPSHOT version")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Static Code Analysis') {
|
stage('Static Code Analysis') {
|
||||||
|
when { expression { findFiles(glob: '**/src/main/java/*.java').length > 0 } }
|
||||||
steps {
|
steps {
|
||||||
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
|
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
|
||||||
sh "${mvn} compile checkstyle:checkstyle pmd:pmd"
|
sh "${mvn} compile checkstyle:checkstyle pmd:pmd"
|
||||||
|
@ -27,25 +29,22 @@ pipeline {
|
||||||
pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: ''
|
pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Build') {
|
stage('Build Java 9') {
|
||||||
parallel {
|
|
||||||
stage('Java 8') {
|
|
||||||
steps {
|
|
||||||
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
|
|
||||||
sh "${mvn} clean install"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Java 9') {
|
|
||||||
steps {
|
steps {
|
||||||
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') {
|
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') {
|
||||||
sh "${mvn} clean install"
|
sh "${mvn} clean install"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Build Java 8') {
|
||||||
|
steps {
|
||||||
|
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
|
||||||
|
sh "${mvn} clean install"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Test Results') {
|
stage('Test Results') {
|
||||||
|
when { expression { findFiles(glob: '**/target/surefire-reports/*.xml').length > 0 } }
|
||||||
steps {
|
steps {
|
||||||
junit '**/target/surefire-reports/*.xml'
|
junit '**/target/surefire-reports/*.xml'
|
||||||
jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class'
|
jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class'
|
||||||
|
@ -59,6 +58,7 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Archiving') {
|
stage('Archiving') {
|
||||||
|
when { expression { findFiles(glob: '**/target/*.jar').length > 0 } }
|
||||||
steps {
|
steps {
|
||||||
archiveArtifacts '**/target/*.jar'
|
archiveArtifacts '**/target/*.jar'
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue