Merge pull request #14 from kemitix/jenkins

jenkins: update to latest template
This commit is contained in:
Paul Campbell 2018-03-04 19:24:29 +00:00 committed by GitHub
commit cb86e94228
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 27 deletions

27
Jenkinsfile vendored
View file

@ -1,27 +0,0 @@
pipeline {
agent any
stages {
stage('Prepare') {
steps {
git url: 'git@github.com:kemitix/conditional.git',
branch: '**',
credentialsId: 'github-kemitix'
}
}
stage('Build') {
steps {
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
sh "mvn -B -U clean install"
}
}
}
stage('Deploy') {
when { expression { (env.GIT_BRANCH == 'master') } }
steps {
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
sh "mvn -B -U -P release deploy"
}
}
}
}
}

67
Jenkinsfile.groovy Normal file
View file

@ -0,0 +1,67 @@
final String repoName = "conditional"
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') {
parallel {
stage('Java 8') {
steps {
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 1.8') {
sh "${mvn} clean install"
}
}
}
stage('Java 9') {
steps {
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') {
sh 'mvn clean install'
}
}
}
}
}
stage('Test Results') {
steps {
junit '**/target/surefire-reports/*.xml'
}
}
stage('Archiving') {
steps {
archiveArtifacts '**/target/*.jar'
}
}
stage('Coverage') {
steps {
jacoco(execPattern: '**/target/jacoco.exec')
}
}
stage('Deploy') {
when { expression { (env.GIT_BRANCH == 'master') } }
steps {
withMaven(maven: 'maven 3.5.2', jdk: 'JDK 9') {
sh "${mvn} deploy --activate-profiles release -DskipTests=true"
}
}
}
}
}

1
lombok.config Normal file
View file

@ -0,0 +1 @@
lombok.addGeneratedAnnotation=false