kemitix-parent/Jenkinsfile.groovy

68 lines
2 KiB
Groovy
Raw Permalink Normal View History

2018-06-30 12:12:20 +01:00
final String mvn = "mvn --batch-mode --update-snapshots --errors --debug"
final dependenciesSupportJDK = 10
2018-03-04 17:37:23 +00:00
pipeline {
agent any
stages {
2018-06-30 12:12:20 +01:00
stage('release != SNAPSHOT') {
// checks that the pom version is not a SNAPSHOT when the current branch is a release
2018-03-04 17:37:23 +00:00
when {
expression {
2018-06-30 12:12:20 +01:00
(branchStartsWith('release/')) &&
2018-03-09 19:34:24 +00:00
(readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT")
}
2018-03-04 17:37:23 +00:00
}
steps {
2018-06-30 12:12:20 +01:00
error("Build failed because SNAPSHOT version: [" + env.GIT_BRANCH + "]")
2018-03-11 19:25:50 +00:00
}
}
2018-06-30 12:12:20 +01:00
stage('Install') {
2018-03-11 19:25:50 +00:00
steps {
2018-06-30 12:21:26 +01:00
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
2018-06-30 12:12:20 +01:00
sh "${mvn} -DskipTests install"
}
}
}
2018-06-30 12:12:20 +01:00
stage('Deploy (release on gitlab)') {
when {
expression {
(branchStartsWith('release/') && isPublished())
}
2018-03-09 19:34:24 +00:00
}
steps {
2018-06-30 12:21:26 +01:00
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
2018-06-30 12:12:20 +01:00
sh "${mvn} --activate-profiles release deploy"
}
}
}
2018-06-30 12:12:20 +01:00
stage('Build Java 9') {
when { expression { dependenciesSupportJDK >= 9 } }
2018-03-04 17:50:56 +00:00
steps {
2018-06-30 12:12:20 +01:00
withMaven(maven: 'maven', jdk: 'JDK 9') {
sh "${mvn} clean verify -Djava.version=9"
2018-03-04 17:37:23 +00:00
}
}
}
2018-06-30 12:12:20 +01:00
stage('Build Java 10') {
when { expression { dependenciesSupportJDK >= 10 } }
2018-03-04 17:37:23 +00:00
steps {
2018-06-30 12:12:20 +01:00
withMaven(maven: 'maven', jdk: 'JDK 10') {
sh "${mvn} clean verify -Djava.version=10"
2018-03-04 17:37:23 +00:00
}
}
}
}
}
2018-06-30 12:12:20 +01: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)
}