Paul Campbell
daa80486e3
There is no java code, so test builds for java 9 and 10 are pointless. Snapshot in release branch should only prevent deploy, not a failed build
49 lines
1.3 KiB
Groovy
49 lines
1.3 KiB
Groovy
final String publicRepo = 'https://github.com/kemitix/'
|
|
final String mvn = "mvn --batch-mode --update-snapshots --errors"
|
|
|
|
pipeline {
|
|
agent any
|
|
stages {
|
|
stage('Install') {
|
|
steps {
|
|
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
|
|
sh "${mvn} -DskipTests install"
|
|
}
|
|
}
|
|
}
|
|
stage('Deploy (published release branch)') {
|
|
when {
|
|
expression {
|
|
(isReleaseBranch() &&
|
|
isPublished(publicRepo) &&
|
|
notSnapshot())
|
|
}
|
|
}
|
|
steps {
|
|
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
|
|
sh "${mvn} --activate-profiles release deploy"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private boolean isReleaseBranch() {
|
|
return branchStartsWith('release/')
|
|
}
|
|
|
|
private boolean branchStartsWith(final String branchName) {
|
|
startsWith(env.GIT_BRANCH, branchName)
|
|
}
|
|
|
|
private boolean isPublished(final String repo) {
|
|
startsWith(env.GIT_URL, repo)
|
|
}
|
|
|
|
private static boolean startsWith(final String value, final String match) {
|
|
value != null && value.startsWith(match)
|
|
}
|
|
|
|
private boolean notSnapshot() {
|
|
return !(readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT")
|
|
}
|