jenkins: only deploy when published to github

This commit is contained in:
Paul Campbell 2018-07-07 08:39:37 +01:00
parent 1957d3f3d4
commit 6acc6e0876

View file

@ -1,3 +1,4 @@
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 final Integer dependenciesSupportJDK = 10
@ -23,10 +24,10 @@ pipeline {
} }
} }
} }
stage('Deploy (release on gitlab)') { stage('Deploy (published release branch)') {
when { when {
expression { expression {
(branchStartsWith('release/') && isPublished()) (branchStartsWith('release/') && isPublished(publicRepo))
} }
} }
steps { steps {
@ -58,10 +59,11 @@ private boolean branchStartsWith(String branchName) {
startsWith(env.GIT_BRANCH, branchName) startsWith(env.GIT_BRANCH, branchName)
} }
private boolean isPublished() { private boolean isPublished(repo) {
startsWith(env.GIT_URL, 'https://') startsWith(env.GIT_URL, repo)
} }
private boolean startsWith(String value, String match) { private boolean startsWith(String value, String match) {
value != null && value.startsWith(match) value != null && value.startsWith(match)
} }