node/Jenkinsfile.groovy
Paul Campbell daf9821887
Switch to trunk-based-development (#34)
* pom.xml: version set to 0.8.0-SNAPSHOT

* jenkins: added

* mvn: add wrapper 3.5.3

* Upgrade parent to 5.1.0

* lombok: upgraded to 1.16.20

* assertj: upgraded to 3.9.1

* coveralls: removed

* kemitix-maven-tiles: added

* kemitix-checkstyle: tile added

* Compile with java 1.8

* Reduce code coverage requirements

* LICENSE: update

* checkstyle: suppress outstanding npath complexity issues, etc

* Bump kemitix-parent from 5.1.0 to 5.1.1

Bumps [kemitix-parent](https://github.com/kemitix/kemitix-parent) from 5.1.0 to 5.1.1.
- [Release notes](https://github.com/kemitix/kemitix-parent/releases)
- [Changelog](https://github.com/kemitix/kemitix-parent/blob/master/CHANGELOG)
- [Commits](https://github.com/kemitix/kemitix-parent/compare/v5.1.0...v5.1.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump tiles-maven-plugin from 2.10 to 2.12

Bumps [tiles-maven-plugin](https://github.com/repaint-io/maven-tiles) from 2.10 to 2.12.
- [Release notes](https://github.com/repaint-io/maven-tiles/releases)
- [Changelog](https://github.com/repaint-io/maven-tiles/blob/master/CHANGELOG.adoc)
- [Commits](https://github.com/repaint-io/maven-tiles/compare/tiles-maven-plugin-2.10...tiles-maven-plugin-2.12)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump assertj-core from 3.9.1 to 3.11.0

Bumps [assertj-core](https://github.com/joel-costigliola/assertj-core) from 3.9.1 to 3.11.0.
- [Release notes](https://github.com/joel-costigliola/assertj-core/releases)
- [Commits](https://github.com/joel-costigliola/assertj-core/compare/assertj-core-3.9.1...assertj-core-3.11.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump lombok from 1.16.20 to 1.18.2

Bumps [lombok](https://github.com/rzwitserloot/lombok) from 1.16.20 to 1.18.2.
- [Release notes](https://github.com/rzwitserloot/lombok/releases)
- [Changelog](https://github.com/rzwitserloot/lombok/blob/master/doc/changelog.markdown)
- [Commits](https://github.com/rzwitserloot/lombok/compare/v1.16.20...v1.18.2)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump assertj-core from 3.11.0 to 3.11.1

Bumps [assertj-core](https://github.com/joel-costigliola/assertj-core) from 3.11.0 to 3.11.1.
- [Release notes](https://github.com/joel-costigliola/assertj-core/releases)
- [Commits](https://github.com/joel-costigliola/assertj-core/compare/assertj-core-3.11.0...assertj-core-3.11.1)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Bump kemitix-parent from 5.1.1 to 5.2.0

Bumps [kemitix-parent](https://gitlab.com/kemitix/kemitix-parent) from 5.1.1 to 5.2.0.
- [Release notes](https://gitlab.com/kemitix/kemitix-parent/tags)
- [Commits](https://gitlab.com/kemitix/kemitix-parent/commits/master)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Update CHANGELOG

* Update Jenkinsfile

* Remove maven wrapper

* Remove travis config

* Simplify .gitignore

* [readme] convert to org-mode format

* lombok scope is provided

* version set to DEV-SNAPSHOT

* rename property kemitix-tiles as kemitix-maven-tiles

* Bump kemitix-maven-tiles from 0.8.1 to 1.3.0

* Bump kemitix-maven-tiles from 1.3.0 to 1.3.1

* NoteItem remove @ToString

* Narrow scope of forceParent to package-private

* [coverage] set required instructions covered to 97%
2018-10-09 22:08:43 +01:00

106 lines
3.8 KiB
Groovy

final String publicRepo = 'https://github.com/kemitix/'
final String mvn = "mvn --batch-mode --update-snapshots --errors"
final dependenciesSupportJDK = 11
pipeline {
agent any
stages {
stage('Build & Test') {
steps {
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
sh "${mvn} clean compile checkstyle:checkstyle pmd:pmd test"
// Code Coverage to Codacy
sh "${mvn} 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',
unHealthy:'100'])
}
}
}
stage('Verify & Install') {
steps {
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
sh "${mvn} -DskipTests install"
}
}
}
stage('SonarQube (published)') {
when { expression { isPublished(publicRepo) } }
steps {
withSonarQubeEnv('sonarqube') {
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
sh "${mvn} org.sonarsource.scanner.maven:sonar-maven-plugin:3.4.0.905:sonar"
}
}
}
}
stage('Deploy (published release branch)') {
when {
expression {
(isReleaseBranch() &&
isPublished(publicRepo) &&
notSnapshot())
}
}
steps {
withMaven(maven: 'maven', jdk: 'JDK 1.8') {
sh "${mvn} --activate-profiles release deploy"
}
}
}
stage('Build Java 9') {
when { expression { dependenciesSupportJDK >= 9 } }
steps {
withMaven(maven: 'maven', jdk: 'JDK 9') {
sh "${mvn} clean verify -Djava.version=9"
}
}
}
stage('Build Java 10') {
when { expression { dependenciesSupportJDK >= 10 } }
steps {
withMaven(maven: 'maven', jdk: 'JDK 10') {
sh "${mvn} clean verify -Djava.version=10"
}
}
}
stage('Build Java 11') {
when { expression { dependenciesSupportJDK >= 11 } }
steps {
withMaven(maven: 'maven', jdk: 'JDK 11') {
sh "${mvn} clean verify -Djava.version=11"
}
}
}
}
}
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")
}