kemitix-pmd-ruleset/Jenkinsfile.groovy

68 lines
2 KiB
Groovy
Raw Permalink Normal View History

final String mvn = "mvn --batch-mode --update-snapshots --errors"
final Integer dependenciesSupportJDK = 10
2018-03-07 18:59:14 +00:00
pipeline {
agent any
stages {
stage('release != SNAPSHOT') {
// checks that the pom version is not a SNAPSHOT when the current branch is a release
2018-03-07 18:59:14 +00:00
when {
expression {
(branchStartsWith('release/')) &&
(readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT")
}
}
steps {
error("Build failed because SNAPSHOT version: [" + env.GIT_BRANCH + "]")
2018-03-07 18:59:14 +00:00
}
}
stage('Install') {
2018-03-07 18:59:14 +00:00
steps {
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
sh "${mvn} -DskipTests install"
}
2018-03-07 18:59:14 +00:00
}
}
stage('Deploy (release on gitlab)') {
when {
expression {
(branchStartsWith('release/') && isPublished())
}
}
2018-03-07 18:59:14 +00:00
steps {
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
sh "${mvn} --activate-profiles release deploy"
2018-03-07 18:59:14 +00:00
}
}
}
stage('Build Java 9') {
when { expression { dependenciesSupportJDK >= 9 } }
2018-03-07 18:59:14 +00:00
steps {
withMaven(maven: 'maven', jdk: 'JDK 9') {
sh "${mvn} clean verify -Djava.version=9"
}
2018-03-07 18:59:14 +00:00
}
}
stage('Build Java 10') {
when { expression { dependenciesSupportJDK >= 10 } }
2018-03-07 18:59:14 +00:00
steps {
withMaven(maven: 'maven', jdk: 'JDK 10') {
sh "${mvn} clean verify -Djava.version=10"
2018-03-07 18:59:14 +00:00
}
}
}
}
}
private boolean branchStartsWith(String branchName) {
startsWith(env.GIT_BRANCH, branchName)
}
private boolean isPublished() {
startsWith(env.GIT_URL, 'https://')
}
private boolean startsWith(String value, String match) {
value != null && value.startsWith(match)
}