From 75fe1a336b89b550f0dbd53870fcd365d0ff5cee Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 4 Mar 2018 16:28:12 +0000 Subject: [PATCH 1/4] jenkins: update to latest template --- Jenkinsfile | 27 ------------------- Jenkinsfile.groovy | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 27 deletions(-) delete mode 100644 Jenkinsfile create mode 100644 Jenkinsfile.groovy diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 3efa81b..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,27 +0,0 @@ -pipeline { - agent any - stages { - stage('Prepare') { - steps { - git url: 'git@github.com:kemitix/conditional.git', - branch: '**', - credentialsId: 'github-kemitix' - } - } - stage('Build') { - steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { - sh "mvn -B -U clean install" - } - } - } - stage('Deploy') { - when { expression { (env.GIT_BRANCH == 'master') } } - steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { - sh "mvn -B -U -P release deploy" - } - } - } - } -} diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy new file mode 100644 index 0000000..8664fb9 --- /dev/null +++ b/Jenkinsfile.groovy @@ -0,0 +1,67 @@ +final String repoName = "mon" +final String repoUrl = "git@github.com:kemitix/${repoName}.git" +final String mvn = "mvn --batch-mode --update-snapshots" + +pipeline { + agent any + stages { + stage('Prepare') { + steps { + git url: repoUrl, branch: '**', credentialsId: 'github-kemitix' + } + } + 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') { + parallel { + stage('Java 8') { + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} clean install" + } + } + } + stage('Java 9') { + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { + sh 'mvn clean install' + } + } + } + } + } + stage('Test Results') { + steps { + junit '**/target/surefire-reports/*.xml' + } + } + stage('Archiving') { + steps { + archiveArtifacts '**/target/*.jar' + } + } + stage('Coverage') { + steps { + jacoco(execPattern: '**/target/jacoco.exec') + } + } + 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" + } + } + } + } +} From 9df27f80655703c1444f8b67d5502a963daa3afb Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 4 Mar 2018 18:18:00 +0000 Subject: [PATCH 2/4] lombok.config: added to prevent generated annotation --- lombok.config | 1 + 1 file changed, 1 insertion(+) create mode 100644 lombok.config diff --git a/lombok.config b/lombok.config new file mode 100644 index 0000000..00ebb3e --- /dev/null +++ b/lombok.config @@ -0,0 +1 @@ +lombok.addGeneratedAnnotation=false From 61ceec90fccde3f8fc868c5666770863df820dd7 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 4 Mar 2018 18:18:16 +0000 Subject: [PATCH 3/4] jenkins: fix repo name --- Jenkinsfile.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 8664fb9..871e9a5 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -1,4 +1,4 @@ -final String repoName = "mon" +final String repoName = "conditional" final String repoUrl = "git@github.com:kemitix/${repoName}.git" final String mvn = "mvn --batch-mode --update-snapshots" From 6a4cd3cd2f7b2b7b77524d8ed86aebd8000b576a Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 4 Mar 2018 18:18:49 +0000 Subject: [PATCH 4/4] jenkins: deploy using Java 9 --- Jenkinsfile.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 871e9a5..a62f310 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -58,7 +58,7 @@ pipeline { stage('Deploy') { when { expression { (env.GIT_BRANCH == 'master') } } steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { sh "${mvn} deploy --activate-profiles release -DskipTests=true" } }