diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index aaa00c8..d118553 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -1,33 +1,25 @@ +final String publicRepo = 'https://github.com/kemitix/' final String mvn = "mvn --batch-mode --update-snapshots --errors" final dependenciesSupportJDK=9 pipeline { agent any stages { - stage('master != SNAPSHOT') { - // 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('Build & Test') { steps { - withMaven(maven: 'maven', jdk: 'JDK LTS') { + withMaven(maven: 'maven', jdk: 'JDK 1.8') { sh "${mvn} clean compile checkstyle:checkstyle pmd:pmd test" - //junit '**/target/surefire-reports/*.xml' + // Code Coverage to Codacy sh "${mvn} -pl builder jacoco:report 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`" + // Code Coverage to Jenkins jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class' + // PMD to Jenkins pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' + // Checkstyle to Jenkins step([$class: 'hudson.plugins.checkstyle.CheckStylePublisher', pattern: '**/target/checkstyle-result.xml', healthy:'20', @@ -37,32 +29,32 @@ pipeline { } stage('Verify & Install') { steps { - withMaven(maven: 'maven', jdk: 'JDK LTS') { + withMaven(maven: 'maven', jdk: 'JDK 1.8') { sh "${mvn} -DskipTests install" } } } - stage('SonarQube (github only)') { - when { expression { env.GIT_URL.startsWith('https://github.com') } } + stage('SonarQube (published)') { + when { expression { isPublished(publicRepo) } } steps { withSonarQubeEnv('sonarqube') { - withMaven(maven: 'maven', jdk: 'JDK LTS') { + withMaven(maven: 'maven', jdk: 'JDK 1.8') { sh "${mvn} org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar" } } } } - stage('Archiving') { - when { expression { findFiles(glob: '**/target/*.jar').length > 0 } } - steps { - archiveArtifacts '**/target/*.jar' + stage('Deploy (published release branch)') { + when { + expression { + (isReleaseBranch() && + isPublished(publicRepo) && + notSnapshot()) + } } - } - stage('Deploy (master on github)') { - when { expression { (env.GIT_BRANCH == 'master' && env.GIT_URL.startsWith('https://github.com')) } } steps { - withMaven(maven: 'maven', jdk: 'JDK LTS') { - sh "${mvn} deploy -pl ruleset,tile --activate-profiles release -DskipTests=true" + withMaven(maven: 'maven', jdk: 'JDK 1.8') { + sh "${mvn} -pl ruleset,tile --activate-profiles release deploy" } } } @@ -84,3 +76,23 @@ pipeline { } } } + +private boolean isReleaseBranch() { + return branchStartsWith('release/') +} + +private boolean branchStartsWith(final String branchName) { + startsWith(env.GIT_BRANCH, branchName) +} + +private boolean isPublished(final String repo) { + startsWith(env.GIT_URL, repo) +} + +private static boolean startsWith(final String value, final String match) { + value != null && value.startsWith(match) +} + +private boolean notSnapshot() { + return !(readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT") +} diff --git a/README.md b/README.md index 847301f..1535fcb 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,8 @@ Provides an extensive Checkstyle ruleset for use with Checkstyle, together with [![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/https/oss.sonatype.org/net.kemitix/kemitix-checkstyle-ruleset.svg?style=for-the-badge)](https://oss.sonatype.org/content/repositories/releases/net/kemitix/kemitix-checkstyle-ruleset/) [![Maven Central](https://img.shields.io/maven-central/v/net.kemitix/kemitix-checkstyle-ruleset.svg?style=for-the-badge)](https://search.maven.org/#search|ga|1|g%3A"net.kemitix"%20AND%20a%3A"kemitix-checkstyle-ruleset") -[![SonarQube Coverage](https://img.shields.io/sonar/https/sonarcloud.io/net.kemitix%3Akemitix-checkstyle-ruleset/coverage.svg?style=for-the-badge)](https://sonarcloud.io/dashboard?id=net.kemitix%3Akemitix-checkstyle-ruleset) -[![SonarQube Tech Debt](https://img.shields.io/sonar/https/sonarcloud.io/net.kemitix%3Akemitix-checkstyle-ruleset/tech_debt.svg?style=for-the-badge)](https://sonarcloud.io/dashboard?id=net.kemitix%3Akemitix-checkstyle-ruleset) - -[![Jenkins](https://img.shields.io/jenkins/s/https/jenkins.kemitix.net/job/GitLab/job/kemitix%252Fkemitix-checkstyle-ruleset.svg?style=for-the-badge)](https://jenkins.kemitix.net/job/GitLab/job/kemitix%252Fkemitix-checkstyle-ruleset/) -[![Jenkins tests](https://img.shields.io/jenkins/t/https/jenkins.kemitix.net/job/GitLab/job/kemitix%252Fkemitix-checkstyle-ruleset.svg?style=for-the-badge)](https://jenkins.kemitix.net/job/GitLab/job/kemitix%252Fkemitix-checkstyle-ruleset/) -[![Jenkins coverage](https://img.shields.io/jenkins/c/https/jenkins.kemitix.net/job/GitLab/job/kemitix%252Fkemitix-checkstyle-ruleset.svg?style=for-the-badge)](https://jenkins.kemitix.net/job/GitLab/job/kemitix%252Fkemitix-checkstyle-ruleset/) +[![SonarQube Coverage](https://img.shields.io/sonar/https/sonarcloud.io/net.kemitix.checkstyle%3Akemitix-checkstyle-ruleset/coverage.svg?style=for-the-badge)](https://sonarcloud.io/dashboard?id=net.kemitix%3Akemitix-checkstyle-ruleset) +[![SonarQube Tech Debt](https://img.shields.io/sonar/https/sonarcloud.io/net.kemitix.checkstyle%3Akemitix-checkstyle-ruleset/tech_debt.svg?style=for-the-badge)](https://sonarcloud.io/dashboard?id=net.kemitix%3Akemitix-checkstyle-ruleset) [![Codacy grade](https://img.shields.io/codacy/grade/d57096b0639d496aba9a7e43e7cf5b4c.svg?style=for-the-badge)](https://app.codacy.com/project/kemitix/kemitix-checkstyle-ruleset/dashboard) @@ -43,7 +39,7 @@ The simplest way to use the ruleset is with the maven-tile: true - net.kemitix.checkstyle:tile:4.1.1 + net.kemitix.checkstyle:tile:RELEASE diff --git a/builder/pom.xml b/builder/pom.xml index 67a9fe0..25cfe4c 100644 --- a/builder/pom.xml +++ b/builder/pom.xml @@ -7,14 +7,14 @@ net.kemitix kemitix-parent - 5.1.0 + 5.1.1 net.kemitix.checkstyle builder jar - 4.1.1 + DEV-SNAPSHOT true @@ -23,30 +23,30 @@ 0.8.1 8.10 - 1.29.0 - 1.16.20 + 1.30.0 + 1.18.0 Brussels-SR6 - 1.5.9.RELEASE + 1.5.14.RELEASE 2.3.5 1.0.0 - 2.13.0 - 3.9.0 - 0.3.0 - 2.18.1 + 2.19.0 + 3.10.0 + 0.4.0 + 3.1.6 3.0.0 ${project.version} 5-complexity net/kemitix/checkstyle-${kemitix.checkstyle.ruleset.level}.xml - 1.2 + 1.3.2 - io.spring.platform - platform-bom - ${spring-platform.version} + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} pom import diff --git a/builder/src/main/resources/README-template.md b/builder/src/main/resources/README-template.md index 1f6edbe..90679f6 100644 --- a/builder/src/main/resources/README-template.md +++ b/builder/src/main/resources/README-template.md @@ -2,6 +2,14 @@ Provides an extensive Checkstyle ruleset for use with Checkstyle, together with a fully configured maven-tile. +[![Sonatype Nexus (Releases)](https://img.shields.io/nexus/r/https/oss.sonatype.org/net.kemitix/kemitix-checkstyle-ruleset.svg?style=for-the-badge)](https://oss.sonatype.org/content/repositories/releases/net/kemitix/kemitix-checkstyle-ruleset/) +[![Maven Central](https://img.shields.io/maven-central/v/net.kemitix/kemitix-checkstyle-ruleset.svg?style=for-the-badge)](https://search.maven.org/#search|ga|1|g%%3A"net.kemitix"%%20AND%%20a%%3A"kemitix-checkstyle-ruleset") + +[![SonarQube Coverage](https://img.shields.io/sonar/https/sonarcloud.io/net.kemitix.checkstyle%%3Akemitix-checkstyle-ruleset/coverage.svg?style=for-the-badge)](https://sonarcloud.io/dashboard?id=net.kemitix%%3Akemitix-checkstyle-ruleset) +[![SonarQube Tech Debt](https://img.shields.io/sonar/https/sonarcloud.io/net.kemitix.checkstyle%%3Akemitix-checkstyle-ruleset/tech_debt.svg?style=for-the-badge)](https://sonarcloud.io/dashboard?id=net.kemitix%%3Akemitix-checkstyle-ruleset) + +[![Codacy grade](https://img.shields.io/codacy/grade/d57096b0639d496aba9a7e43e7cf5b4c.svg?style=for-the-badge)](https://app.codacy.com/project/kemitix/kemitix-checkstyle-ruleset/dashboard) + The ruleset includes checks from both the core Checkstyle library and from the Sevntu-Checkstyle library. * [Usage](#usage) @@ -31,7 +39,7 @@ The simplest way to use the ruleset is with the maven-tile: true - net.kemitix.checkstyle:tile:4.1.1 + net.kemitix.checkstyle:tile:RELEASE diff --git a/ruleset/pom.xml b/ruleset/pom.xml index 0082091..5ab04bd 100644 --- a/ruleset/pom.xml +++ b/ruleset/pom.xml @@ -7,13 +7,13 @@ net.kemitix kemitix-parent - 5.1.0 + 5.1.1 net.kemitix.checkstyle ruleset - 4.1.1 + DEV-SNAPSHOT jar Kemitix Checkstyle Ruleset @@ -22,8 +22,7 @@ 2.11 - 0.8.1 - 3.0.2 + 0.9.0 @@ -62,14 +61,6 @@ - - org.apache.maven.plugins - maven-resources-plugin - ${maven-resources-plugin.version} - - UTF-8 - - diff --git a/tile/pom.xml b/tile/pom.xml index 722ade6..748210f 100644 --- a/tile/pom.xml +++ b/tile/pom.xml @@ -5,14 +5,14 @@ net.kemitix kemitix-parent - 5.1.0 + 5.1.1 4.0.0 net.kemitix.checkstyle tile - 4.1.1 + DEV-SNAPSHOT tile diff --git a/tile/tile.xml b/tile/tile.xml index a533e9f..e0393c8 100644 --- a/tile/tile.xml +++ b/tile/tile.xml @@ -3,7 +3,7 @@ 3.0.0 8.10 1.29.0 - 4.1.1 + DEV-SNAPSHOT 5-complexity net/kemitix/checkstyle-${kemitix.checkstyle.ruleset.level}.xml