2018-07-07 08:39:37 +01:00
|
|
|
final String publicRepo = 'https://github.com/kemitix/'
|
2018-07-03 07:25:48 +01:00
|
|
|
final String mvn = "mvn --batch-mode --update-snapshots --errors"
|
2018-03-04 17:37:23 +00:00
|
|
|
|
|
|
|
pipeline {
|
|
|
|
agent any
|
|
|
|
stages {
|
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-03-08 22:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-07-07 08:39:37 +01:00
|
|
|
stage('Deploy (published release branch)') {
|
2018-06-30 12:12:20 +01:00
|
|
|
when {
|
|
|
|
expression {
|
2018-07-07 12:00:42 +01:00
|
|
|
(isReleaseBranch() &&
|
|
|
|
isPublished(publicRepo) &&
|
|
|
|
notSnapshot())
|
2018-03-08 22:26:31 +00:00
|
|
|
}
|
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-03-08 22:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-04 17:37:23 +00:00
|
|
|
}
|
|
|
|
}
|
2018-06-30 12:12:20 +01:00
|
|
|
|
2018-07-07 12:00:42 +01:00
|
|
|
private boolean isReleaseBranch() {
|
|
|
|
return branchStartsWith('release/')
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean branchStartsWith(final String branchName) {
|
2018-06-30 12:12:20 +01:00
|
|
|
startsWith(env.GIT_BRANCH, branchName)
|
|
|
|
}
|
|
|
|
|
2018-07-07 12:00:42 +01:00
|
|
|
private boolean isPublished(final String repo) {
|
2018-07-07 08:39:37 +01:00
|
|
|
startsWith(env.GIT_URL, repo)
|
2018-06-30 12:12:20 +01:00
|
|
|
}
|
|
|
|
|
2018-07-07 12:00:42 +01:00
|
|
|
private static boolean startsWith(final String value, final String match) {
|
2018-06-30 12:12:20 +01:00
|
|
|
value != null && value.startsWith(match)
|
|
|
|
}
|
2018-07-07 08:39:37 +01:00
|
|
|
|
2018-07-07 12:00:42 +01:00
|
|
|
private boolean notSnapshot() {
|
|
|
|
return !(readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT")
|
|
|
|
}
|