Merge pull request #81 from kemitix/jenkins

Jenkins clean up
This commit is contained in:
Paul Campbell 2018-04-19 20:50:45 +01:00 committed by GitHub
commit 67952af227
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 55 additions and 91 deletions

@ -1 +0,0 @@
Subproject commit b97def251b784ecc8de6d3cc30d2793ac0bd375e

View file

@ -1,18 +1,9 @@
// non-standard Jenkinsfile
// * only publish code coverage to codacy for builder module
// * only deploy artifacts for ruleset and tile modules
final String mvn = "mvn --batch-mode --update-snapshots" final String mvn = "mvn --batch-mode --update-snapshots"
pipeline { pipeline {
agent any agent any
stages { stages {
stage('Environment') { stage('master != SNAPSHOT') {
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 // checks that the pom version is not a snapshot when the current or target branch is master
when { when {
expression { expression {
@ -24,19 +15,34 @@ pipeline {
error("Build failed because SNAPSHOT version") error("Build failed because SNAPSHOT version")
} }
} }
stage('Static Code Analysis') { stage('Build & Test') {
when { expression { findFiles(glob: '**/src/main/java/**/*.java').length > 0 } }
steps { steps {
withMaven(maven: 'maven', jdk: 'JDK LTS') { withMaven(maven: 'maven', jdk: 'JDK LTS') {
sh "${mvn} compile" sh "${mvn} clean compile checkstyle:checkstyle pmd:pmd test"
sh "${mvn} checkstyle:checkstyle" //junit '**/target/surefire-reports/*.xml'
sh "${mvn} pmd:pmd" 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`"
jacoco exclusionPattern: '**/*{Test|IT|Main|Application|Immutable}.class'
pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: '' pmd canComputeNew: false, defaultEncoding: '', healthy: '', pattern: '', unHealthy: ''
step([$class: 'hudson.plugins.checkstyle.CheckStylePublisher',
pattern: '**/target/checkstyle-result.xml',
healthy:'20',
unHealthy:'100'])
} }
} }
} }
stage('SonarQube (develop only)') { stage('Verify & Install') {
when { expression { env.GIT_BRANCH == 'develop' && env.GIT_URL.startsWith('https://') } } steps {
withMaven(maven: 'maven', jdk: 'JDK LTS') {
sh "${mvn} -DskipTests install"
}
}
}
stage('SonarQube (github only)') {
when { expression { env.GIT_URL.startsWith('https://github.com') } }
steps { steps {
withSonarQubeEnv('sonarqube') { withSonarQubeEnv('sonarqube') {
withMaven(maven: 'maven', jdk: 'JDK LTS') { withMaven(maven: 'maven', jdk: 'JDK LTS') {
@ -45,47 +51,24 @@ pipeline {
} }
} }
} }
stage('Build Java Next') {
steps {
withMaven(maven: 'maven', jdk: 'JDK Next') {
sh "${mvn} clean install -Djava.version=9 -Dmaven-enforcer-plugin.version=3.0.0-M1"
//TODO: check that git status is still clean - i.e. builder didn't update any rulesets
}
}
}
stage('Build Java LTS') {
steps {
withMaven(maven: 'maven', jdk: 'JDK LTS') {
sh "${mvn} clean install"
//TODO: check that git status is still clean - i.e. builder didn't update any rulesets
}
}
}
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', jdk: 'JDK LTS') {
sh "${mvn} -pl builder 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') { stage('Archiving') {
when { expression { findFiles(glob: '**/target/*.jar').length > 0 } } when { expression { findFiles(glob: '**/target/*.jar').length > 0 } }
steps { steps {
archiveArtifacts '**/target/*.jar' archiveArtifacts '**/target/*.jar'
} }
} }
stage('Deploy') { stage('Deploy (master on github)') {
when { expression { (env.GIT_BRANCH == 'master' && env.GIT_URL.startsWith('https://')) } } when { expression { (env.GIT_BRANCH == 'master' && env.GIT_URL.startsWith('https://github.com')) } }
steps { steps {
withMaven(maven: 'maven', jdk: 'JDK LTS') { withMaven(maven: 'maven', jdk: 'JDK LTS') {
sh "${mvn} -pl ruleset,tile deploy --activate-profiles release -DskipTests=true" sh "${mvn} deploy --activate-profiles release -DskipTests=true"
}
}
}
stage('Build Java 9') {
steps {
withMaven(maven: 'maven', jdk: 'JDK 9') {
sh "${mvn} clean verify -Djava.version=9"
} }
} }
} }

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.kemitix</groupId> <groupId>net.kemitix</groupId>
<artifactId>kemitix-parent</artifactId> <artifactId>kemitix-parent</artifactId>
<version>5.0.3</version> <version>5.1.0</version>
<relativePath/> <relativePath/>
</parent> </parent>
@ -20,7 +20,7 @@
<maven.install.skip>true</maven.install.skip> <maven.install.skip>true</maven.install.skip>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version> <tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
<kemitix-tiles.version>0.3.0</kemitix-tiles.version> <kemitix-tiles.version>0.8.1</kemitix-tiles.version>
<checkstyle.version>8.7</checkstyle.version> <checkstyle.version>8.7</checkstyle.version>
<sevntu.version>1.27.0</sevntu.version> <sevntu.version>1.27.0</sevntu.version>
@ -142,14 +142,14 @@
<extensions>true</extensions> <extensions>true</extensions>
<configuration> <configuration>
<tiles> <tiles>
<tile>net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version}</tile> <tile>net.kemitix.tiles:maven-plugins:${kemitix-tiles.version}</tile>
<tile>net.kemitix.tiles:enforcer-tile:${kemitix-tiles.version}</tile> <tile>net.kemitix.tiles:enforcer:${kemitix-tiles.version}</tile>
<tile>net.kemitix.tiles:compiler-tile:${kemitix-tiles.version}</tile> <tile>net.kemitix.tiles:compiler:${kemitix-tiles.version}</tile>
<tile>net.kemitix.tiles:huntbugs-tile:${kemitix-tiles.version}</tile> <tile>net.kemitix.tiles:huntbugs:${kemitix-tiles.version}</tile>
<tile>net.kemitix.tiles:pmd-tile:${kemitix-tiles.version}</tile> <tile>net.kemitix.tiles:pmd:${kemitix-tiles.version}</tile>
<tile>net.kemitix.tiles:testing-tile:${kemitix-tiles.version}</tile> <tile>net.kemitix.tiles:testing:${kemitix-tiles.version}</tile>
<tile>net.kemitix.tiles:coverage-tile:${kemitix-tiles.version}</tile> <tile>net.kemitix.tiles:coverage:${kemitix-tiles.version}</tile>
<tile>net.kemitix.tiles:pitest-tile:${kemitix-tiles.version}</tile> <tile>net.kemitix.tiles:pitest:${kemitix-tiles.version}</tile>
</tiles> </tiles>
</configuration> </configuration>
</plugin> </plugin>

View file

@ -1,3 +0,0 @@
test:
override:
- ./mvnw clean install

View file

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>net.kemitix</groupId> <groupId>net.kemitix</groupId>
<artifactId>kemitix-parent</artifactId> <artifactId>kemitix-parent</artifactId>
<version>5.0.3</version> <version>5.1.0</version>
<relativePath/> <relativePath/>
</parent> </parent>
@ -17,8 +17,9 @@
<properties> <properties>
<maven.install.skip>true</maven.install.skip> <maven.install.skip>true</maven.install.skip>
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version> <tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
<kemitix-tiles.version>0.2.0</kemitix-tiles.version> <kemitix-tiles.version>0.8.1</kemitix-tiles.version>
<java.version>1.8</java.version>
<checkstyle.version>8.7</checkstyle.version> <checkstyle.version>8.7</checkstyle.version>
<sevntu.version>1.27.0</sevntu.version> <sevntu.version>1.27.0</sevntu.version>
<maven-checkstyle-plugin.version>3.0.0</maven-checkstyle-plugin.version> <maven-checkstyle-plugin.version>3.0.0</maven-checkstyle-plugin.version>
@ -50,8 +51,8 @@
<extensions>true</extensions> <extensions>true</extensions>
<configuration> <configuration>
<tiles> <tiles>
<tile>net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version}</tile> <tile>net.kemitix.tiles:maven-plugins:${kemitix-tiles.version}</tile>
<tile>net.kemitix.tiles:compiler-tile:${kemitix-tiles.version}</tile> <tile>net.kemitix.tiles:compiler:${kemitix-tiles.version}</tile>
</tiles> </tiles>
</configuration> </configuration>
</plugin> </plugin>

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>net.kemitix</groupId> <groupId>net.kemitix</groupId>
<artifactId>kemitix-parent</artifactId> <artifactId>kemitix-parent</artifactId>
<version>5.0.3</version> <version>5.1.0</version>
<relativePath/> <relativePath/>
</parent> </parent>
@ -22,7 +22,7 @@
<properties> <properties>
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version> <tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
<kemitix-tiles.version>0.2.0</kemitix-tiles.version> <kemitix-tiles.version>0.8.1</kemitix-tiles.version>
<maven-resources-plugin.version>3.0.2</maven-resources-plugin.version> <maven-resources-plugin.version>3.0.2</maven-resources-plugin.version>
</properties> </properties>
@ -57,9 +57,8 @@
<extensions>true</extensions> <extensions>true</extensions>
<configuration> <configuration>
<tiles> <tiles>
<tile>net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version}</tile> <tile>net.kemitix.tiles:maven-plugins:${kemitix-tiles.version}</tile>
<tile>net.kemitix.tiles:enforcer-tile:${kemitix-tiles.version}</tile> <tile>net.kemitix.tiles:enforcer:${kemitix-tiles.version}</tile>
<tile>net.kemitix.tiles:release-tile:${kemitix-tiles.version}</tile>
</tiles> </tiles>
</configuration> </configuration>
</plugin> </plugin>

View file

@ -1,8 +0,0 @@
language: java
jdk:
- oraclejdk8
cache:
directories:
- "$HOME/.m2"
install: true
script: "./mvnw clean install"

View file

@ -5,7 +5,7 @@
<parent> <parent>
<groupId>net.kemitix</groupId> <groupId>net.kemitix</groupId>
<artifactId>kemitix-parent</artifactId> <artifactId>kemitix-parent</artifactId>
<version>5.0.3</version> <version>5.1.0</version>
<relativePath/> <relativePath/>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -18,7 +18,7 @@
<properties> <properties>
<tiles-maven-plugin.version>2.10</tiles-maven-plugin.version> <tiles-maven-plugin.version>2.10</tiles-maven-plugin.version>
<kemitix-tiles.version>0.2.0</kemitix-tiles.version> <kemitix-tiles.version>0.8.1</kemitix-tiles.version>
</properties> </properties>
<build> <build>
@ -30,8 +30,7 @@
<extensions>true</extensions> <extensions>true</extensions>
<configuration> <configuration>
<tiles> <tiles>
<tile>net.kemitix.tiles:maven-plugins-tile:${kemitix-tiles.version}</tile> <tile>net.kemitix.tiles:maven-plugins:${kemitix-tiles.version}</tile>
<tile>net.kemitix.tiles:release-tile:${kemitix-tiles.version}</tile>
</tiles> </tiles>
</configuration> </configuration>
</plugin> </plugin>

View file

@ -1,6 +0,0 @@
box: maven:3.5.0-jdk-8
build:
steps:
- xenoterracide/maven:
goals: clean install