2018-03-04 17:37:23 +00:00
|
|
|
final String repoName = "kemitix-parent"
|
|
|
|
final String repoUrl = "git@github.com:kemitix/${repoName}.git"
|
|
|
|
final String mvn = "mvn --batch-mode --update-snapshots"
|
|
|
|
|
|
|
|
pipeline {
|
|
|
|
agent any
|
|
|
|
stages {
|
|
|
|
stage('Prepare') {
|
|
|
|
steps {
|
|
|
|
git url: repoUrl, 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') {
|
2018-03-04 17:50:56 +00:00
|
|
|
steps {
|
|
|
|
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') {
|
|
|
|
sh 'mvn clean install'
|
2018-03-04 17:37:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Archiving') {
|
|
|
|
steps {
|
|
|
|
archiveArtifacts 'pom.xml'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage('Deploy') {
|
|
|
|
when { expression { (env.GIT_BRANCH == 'master') } }
|
|
|
|
steps {
|
2018-03-04 17:50:56 +00:00
|
|
|
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') {
|
2018-03-04 17:37:23 +00:00
|
|
|
sh "${mvn} deploy --activate-profiles release -DskipTests=true"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|