From fd78eeece6fcea23c6a09fd3225e64c7aabde67e Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 8 Mar 2018 22:25:39 +0000 Subject: [PATCH] jenkins: report environment, no snapshots in PRs to master and only deploy from https repos --- Jenkinsfile.groovy | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index e799493..02c109f 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -3,12 +3,16 @@ final String mvn = "mvn --batch-mode --update-snapshots" pipeline { agent any stages { + stage('Environment') { + steps { + sh 'set' + } + } stage('no SNAPSHOT in master') { - // checks that the pom version is not a snapshot when the current branch is master - // TODO: also check for SNAPSHOT when is a pull request with master as the target branch + // checks that the pom version is not a snapshot when the current or target branch is master when { expression { - (env.GIT_BRANCH == 'master') && + (env.GIT_BRANCH == 'master' || env.CHANGE_TARGET == 'master') && (readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT") } } steps { @@ -60,7 +64,7 @@ pipeline { } } stage('Deploy') { - when { expression { (env.GIT_BRANCH == 'master') } } + when { expression { (env.GIT_BRANCH == 'master' && env.GIT_URL.startsWith('https://')) } } steps { withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { sh "${mvn} deploy --activate-profiles release -DskipTests=true"