2018-03-01 19:41:28 +00:00
|
|
|
final String gitRepoUrl = 'git@github.com:kemitix/mon.git'
|
|
|
|
final String mvn = "mvn --batch-mode --update-snapshots"
|
2018-03-03 09:22:28 +00:00
|
|
|
final Model pom = readMavenPom file: 'pom.xml'
|
2018-03-01 19:41:28 +00:00
|
|
|
|
|
|
|
pipeline {
|
|
|
|
agent any
|
|
|
|
stages {
|
|
|
|
stage('Prepare') {
|
|
|
|
steps {
|
|
|
|
git url: gitRepoUrl, branch: '**', credentialsId: 'github-kemitix'
|
|
|
|
}
|
|
|
|
}
|
2018-03-03 08:46:47 +00:00
|
|
|
stage('no SNAPSHOT in master') {
|
|
|
|
// checks that the pom version is not a snapshot when the current branch is master
|
2018-03-03 09:03:35 +00:00
|
|
|
// TODO: also check for SNAPSHOT when is a pull request with master as the target branch
|
|
|
|
when {
|
|
|
|
expression {
|
|
|
|
(env.GIT_BRANCH == 'master') &&
|
|
|
|
(pom.version).contains("SNAPSHOT") }
|
|
|
|
}
|
2018-03-03 08:46:47 +00:00
|
|
|
steps {
|
2018-03-03 09:03:35 +00:00
|
|
|
error("Build failed because SNAPSHOT version: ${pom.groupId}:${pom.artifactId}:${pom.version}")
|
2018-03-03 08:46:47 +00:00
|
|
|
}
|
|
|
|
}
|
2018-03-01 19:41:28 +00:00
|
|
|
stage('Build') {
|
|
|
|
parallel {
|
|
|
|
stage('Java 8') {
|
|
|
|
steps {
|
|
|
|
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
|
|
|
|
sh 'mvn clean install'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-01 20:11:05 +00:00
|
|
|
// 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'
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
2018-03-01 19:41:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|