From b45f07228c8799662f7abb352ca6cff8c29072da Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 8 Mar 2018 18:15:55 +0000 Subject: [PATCH 1/4] jenkins: update jenkinsfile template --- Jenkinsfile.groovy | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 6c74e11..e799493 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -1,15 +1,8 @@ -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 @@ -22,6 +15,14 @@ pipeline { error("Build failed because SNAPSHOT version") } } + stage('Static Code Analysis') { + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} compile checkstyle:checkstyle pmd:pmd" + } + pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' + } + } stage('Build') { parallel { stage('Java 8') { @@ -34,7 +35,7 @@ pipeline { stage('Java 9') { steps { withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { - sh 'mvn clean install' + sh "${mvn} clean install" } } } @@ -43,6 +44,14 @@ pipeline { stage('Test Results') { steps { junit '**/target/surefire-reports/*.xml' + jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} com.gavinmogan:codacy-maven-plugin:coverage " + + "-DcoverageReportFile=target/site/jacoco/jacoco.xml " + + "-DprojectToken=`$JENKINS_HOME/codacy/token` " + + "-DapiToken=`$JENKINS_HOME/codacy/apitoken` " + + "-Dcommit=`git rev-parse HEAD`" + } } } stage('Archiving') { @@ -50,15 +59,10 @@ pipeline { 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 9') { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { sh "${mvn} deploy --activate-profiles release -DskipTests=true" } } From 878001a25fba6b3503aa656580d168efb610ed80 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 8 Mar 2018 18:17:05 +0000 Subject: [PATCH 2/4] travis: remove deploy --- .gitmodules | 3 --- .travis.yml | 10 +--------- 2 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index c50d110..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule ".travis-support"] - path = .travis-support - url = https://github.com/kemitix/kemitix-travis-support.git diff --git a/.travis.yml b/.travis.yml index 1f3bfa4..fcd939b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,12 +5,4 @@ cache: directories: - "$HOME/.m2" install: true -script: "./mvnw clean install" -after_success: -- sh .travis-support/coveralls.sh -- bash <(curl -s https://codecov.io/bash) -deploy: - provider: script - script: sh .travis-support/deploy.sh - on: - branch: master +script: "./mvnw -B -U clean install" From 586546f615a485a5cba0ff386df5ce7bae65c582 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 8 Mar 2018 18:51:13 +0000 Subject: [PATCH 3/4] Dump environment - try #1 --- .travis-support | 1 - Jenkinsfile.groovy | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) delete mode 160000 .travis-support diff --git a/.travis-support b/.travis-support deleted file mode 160000 index b8593e5..0000000 --- a/.travis-support +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b8593e541ba9a11447fa9559a83e5f99097ca4d2 diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index e799493..26d3c15 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -3,6 +3,11 @@ final String mvn = "mvn --batch-mode --update-snapshots" pipeline { agent any stages { + stage('dump 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 From 997e08458e9645106206427eaa1a9d86afb73c68 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Thu, 8 Mar 2018 18:56:59 +0000 Subject: [PATCH 4/4] jenkins: checkfor SNAPSHOT when pull request into master --- Jenkinsfile.groovy | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 26d3c15..0e9f8ea 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -3,17 +3,16 @@ final String mvn = "mvn --batch-mode --update-snapshots" pipeline { agent any stages { - stage('dump environment') { + 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 {