From ecfc3d94cf2e288f0d8995c82df9344bc2b9a24f Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 26 Feb 2018 21:06:12 +0000 Subject: [PATCH] Rewrite Jenkinsfile --- Jenkinsfile | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 880b2ed..d43fdd7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,35 +1,32 @@ +def maven(goals, modules, profiles) { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "mvn -U $profiles $modules $goals" + } +} + +def isBranch(branch) { + return env.GIT_BRANCH == branch +} + pipeline { agent any stages { stage('Prepare') { steps { - checkout([ - $class: 'GitSCM', - branches: [[name: '**']], - extensions: [[$class: 'CleanBeforeCheckout']], - userRemoteConfigs: [[credentialsId: 'github-kemitix', url: 'git@github.com:kemitix/conditional.git']] - ]) + git url: 'git@github.com:kemitix/condition.git', + branch: '**', + credentialsId: 'github-kemitix' } } stage('Build') { steps { - sh './mvnw -B -U clean install' - } - } - stage('Reporting') { - steps { - junit '**/target/surefire-reports/*.xml' - archiveArtifacts '**/target/*.jar' + maven("clean install", ".", "") } } stage('Deploy') { - when { - expression { - env.GIT_BRANCH == 'master' - } - } + when { expression { isBranch 'master' } } steps { - sh './mvnw -B -Dskip-Tests=true -P release deploy' + maven("deploy", allModules, "-P release") } } }