diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index 4e84469..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,28 +0,0 @@ -final String gitRepoUrl = 'git@github.com:kemitix/kemitix-parent.git' -final String mvn = "mvn --batch-mode --update-snapshots" - -pipeline { - agent any - stages { - stage('Prepare') { - steps { - git url: gitRepoUrl, branch: '**', credentialsId: 'github-kemitix' - } - } - stage('Build') { - steps { - withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { - sh "${mvn} clean install" - } - } - } - 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" - } - } - } - } -} diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy new file mode 100644 index 0000000..268e49c --- /dev/null +++ b/Jenkinsfile.groovy @@ -0,0 +1,75 @@ +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 or target branch is master + when { + expression { + (env.GIT_BRANCH == 'master' || env.CHANGE_TARGET == 'master') && + (readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT") + } + } + steps { + error("Build failed because SNAPSHOT version") + } + } + stage('Static Code Analysis') { + when { expression { findFiles(glob: '**/src/main/java/*.java').length > 0 } } + 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 Java 9') { + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') { + sh "${mvn} clean install" + } + } + } + stage('Build Java 8') { + steps { + withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') { + sh "${mvn} clean install" + } + } + } + stage('Test Results') { + when { expression { findFiles(glob: '**/target/surefire-reports/*.xml').length > 0 } } + 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') { + when { expression { findFiles(glob: '**/target/*.jar').length > 0 } } + steps { + archiveArtifacts '**/target/*.jar' + } + } + stage('Deploy') { + 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" + } + } + } + } +} 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 diff --git a/pom.xml b/pom.xml index c06ec1b..5c0eb3f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ net.kemitix kemitix-parent - 5.1.0 + 5.2.0-SNAPSHOT pom Kemitix Parent diff --git a/set-version.sh b/set-version.sh index 61099c3..f882f33 100644 --- a/set-version.sh +++ b/set-version.sh @@ -1,15 +1,19 @@ #!/usr/bin/env bash +cd `dirname $0` +PROJECT=`basename $PWD` + if test $# != 1 then echo "next version missing" exit fi -CURRENT=`grep '' pom.xml |head -n 1| sed 's/.*>\(.*\)<.*/\1/'` +CURRENT=`grep -C 2 "${PROJECT}" pom.xml | grep '' | sed 's/.*>\(.*\)<.*/\1/'` NEXT=$1 echo Updating version from $CURRENT to $NEXT ./mvnw versions:set -DnewVersion=$NEXT -perl -p -i -e "s,$CURRENT