Update format
This commit is contained in:
parent
bc7516fd82
commit
ea5d1e0c4a
1 changed files with 33 additions and 50 deletions
|
@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue