jenkins: remove redundant steps
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
This commit is contained in:
parent
6acc6e0876
commit
daa80486e3
1 changed files with 13 additions and 33 deletions
|
@ -1,22 +1,9 @@
|
||||||
final String publicRepo = 'https://github.com/kemitix/'
|
final String publicRepo = 'https://github.com/kemitix/'
|
||||||
final String mvn = "mvn --batch-mode --update-snapshots --errors"
|
final String mvn = "mvn --batch-mode --update-snapshots --errors"
|
||||||
final Integer dependenciesSupportJDK = 10
|
|
||||||
|
|
||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
stages {
|
stages {
|
||||||
stage('release != SNAPSHOT') {
|
|
||||||
// checks that the pom version is not a SNAPSHOT when the current branch is a release
|
|
||||||
when {
|
|
||||||
expression {
|
|
||||||
(branchStartsWith('release/')) &&
|
|
||||||
(readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
error("Build failed because SNAPSHOT version: [" + env.GIT_BRANCH + "]")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Install') {
|
stage('Install') {
|
||||||
steps {
|
steps {
|
||||||
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
|
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
|
||||||
|
@ -27,7 +14,9 @@ pipeline {
|
||||||
stage('Deploy (published release branch)') {
|
stage('Deploy (published release branch)') {
|
||||||
when {
|
when {
|
||||||
expression {
|
expression {
|
||||||
(branchStartsWith('release/') && isPublished(publicRepo))
|
(isReleaseBranch() &&
|
||||||
|
isPublished(publicRepo) &&
|
||||||
|
notSnapshot())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
steps {
|
steps {
|
||||||
|
@ -36,34 +25,25 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Build Java 9') {
|
|
||||||
when { expression { dependenciesSupportJDK >= 9 } }
|
|
||||||
steps {
|
|
||||||
withMaven(maven: 'maven', jdk: 'JDK 9') {
|
|
||||||
sh "${mvn} clean verify -Djava.version=9"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Build Java 10') {
|
|
||||||
when { expression { dependenciesSupportJDK >= 10 } }
|
|
||||||
steps {
|
|
||||||
withMaven(maven: 'maven', jdk: 'JDK 10') {
|
|
||||||
sh "${mvn} clean verify -Djava.version=10"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean branchStartsWith(String branchName) {
|
private boolean isReleaseBranch() {
|
||||||
|
return branchStartsWith('release/')
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean branchStartsWith(final String branchName) {
|
||||||
startsWith(env.GIT_BRANCH, branchName)
|
startsWith(env.GIT_BRANCH, branchName)
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPublished(repo) {
|
private boolean isPublished(final String repo) {
|
||||||
startsWith(env.GIT_URL, repo)
|
startsWith(env.GIT_URL, repo)
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean startsWith(String value, String match) {
|
private static boolean startsWith(final String value, final String match) {
|
||||||
value != null && value.startsWith(match)
|
value != null && value.startsWith(match)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean notSnapshot() {
|
||||||
|
return !(readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue