mon/Jenkinsfile.groovy
Paul Campbell a7b4bc3d12 Merge branch 'develop' into jdk-9-compatible
* develop:
  Add missing error when snapshot
  version set to 0.6.0-SNAPSHOT (again)
  jenkins: use mvn with options
  jenkins: clean up
  jenkins: fix syntax #5
  jenkins: fix syntax #4
  jenkins: fix syntax #3
  jenkins: strong type read pom
  jenkins: fix syntax #2
  jenkins: fix syntax #2
  jenkins: fix syntax
  jenkins: fix syntax
  Revert "version set to 0.6.0-SNAPSHOT"
  jenkins: add check to fail build when SNAPSHOT on master branch
  version set to 0.6.0-SNAPSHOT
  pom: fix accidental merge of SNAPSHOT into master
  version: set to 0.6.0-SNAPSHOT
  version: set to 0.5.0
2018-03-03 13:27:35 +00:00

58 lines
2 KiB
Groovy

final String gitRepoUrl = 'git@github.com:kemitix/mon.git'
final String mvn = "mvn --batch-mode --update-snapshots"
pipeline {
agent any
stages {
stage('Prepare') {
steps {
git url: gitRepoUrl, branch: '**', credentialsId: 'github-kemitix'
}
}
stage('no SNAPSHOT in master') {
// checks that the pom version is not a snapshot when the current branch is master
// TODO: also check for SNAPSHOT when is a pull request with master as the target branch
when {
expression {
(env.GIT_BRANCH == 'master') &&
(readMavenPom(file: 'pom.xml').version).contains("SNAPSHOT") }
}
steps {
error("Build failed because SNAPSHOT version")
}
}
stage('Build') {
parallel {
stage('Java 8') {
steps {
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
sh "${mvn} clean install"
}
}
}
// requires maven-failsafe-plugin:2.21 when it is released
stage('Java 9') {
steps {
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') {
sh 'mvn clean install'
}
}
}
}
}
stage('Reporting') {
steps {
junit '**/target/surefire-reports/*.xml'
archiveArtifacts '**/target/*.jar'
}
}
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 -DskipTests=true"
}
}
}
}
}