From 76e95080bf94748c975e43ee9f42b5e3f1590de9 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Wed, 7 Mar 2018 18:59:14 +0000 Subject: [PATCH] jenkins: add jenkinsfile --- Jenkinsfile.groovy | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Jenkinsfile.groovy diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy new file mode 100644 index 0000000..14588d2 --- /dev/null +++ b/Jenkinsfile.groovy @@ -0,0 +1,39 @@ +final String mvn = "mvn --batch-mode --update-snapshots" + +pipeline { + agent any + stages { + 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 + when { + expression { + (env.GIT_BRANCH == 'master') && + (readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT") } + } + steps { + error("Build failed because SNAPSHOT version") + } + } + stage('Build') { + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { + sh 'mvn clean install' + } + } + } + stage('Archiving') { + steps { + archiveArtifacts '**/classes/**/*.xml' + } + } + stage('Deploy') { + when { expression { (env.GIT_BRANCH == 'master') } } + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} deploy --activate-profiles release -DskipTests=true" + } + } + } + } +}