Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.

Commit

Permalink
#3 Migrate Jenkinsfile from Scripted Pipeline to Declarative Pipeline
Browse files Browse the repository at this point in the history
- migrate to Jenkins Declarative Pipeline
- refactor travis configuration (use install and script commands)
  • Loading branch information
agabrys committed Mar 25, 2018
1 parent 0755de9 commit 1f75096
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 37 deletions.
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
language: java
script: mvn -e clean install site
jdk:
- oraclejdk9
- oraclejdk8
- oraclejdk7
- openjdk7
- openjdk6
after_success:
- mvn -e coveralls:report
install: mvn -B -V -e package -DskipTests
script: mvn -B -e verify site
after_success: mvn -B -e coveralls:report
71 changes: 39 additions & 32 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
properties([[
$class: 'BuildDiscarderProperty',
strategy: [
$class: 'LogRotator',
artifactDaysToKeepStr: '-1',
artifactNumToKeepStr: '10',
daysToKeepStr: '-1',
numToKeepStr: '10'
]
]])

node {
timestamps {
stage('Pre Build Cleanup') {
step($class: 'WsCleanup')
}
stage('Checkout') {
checkout scm
}

withMaven(maven: 'MVN-3', jdk: 'JDK-8', mavenLocalRepo: '.repository') {
stage('Build') {
sh 'mvn -e install site -DskipTests'
pipeline {
agent any
options {
buildDiscarder(logRotator(artifactDaysToKeepStr: '-1', artifactNumToKeepStr: '10', daysToKeepStr: '-1', numToKeepStr: '10'))
timestamps()
}
tools {
// withMaven ignores tools: https://issues.jenkins-ci.org/browse/JENKINS-43651
maven 'MVN-3'
jdk 'JDK-9'
}
environment {
MAVEN_ARGS = '-e -Dmaven.repo.local=.repository'
}
stages {
stage('Build') {
steps {
withMaven(maven: 'MVN-3', jdk: 'JDK-9', publisherStrategy: 'EXPLICIT', options: [
artifactsPublisher(disabled: false), dependenciesFingerprintPublisher(disabled: false), openTasksPublisher(disabled: false)
]) {
sh "mvn ${MAVEN_ARGS} package -DskipTests"
}
}
stage('Test') {
sh 'mvn -e test'
junit 'target/surefire-reports/TEST-*.xml'
}
stage('Verify') {
steps {
withMaven(maven: 'MVN-3', jdk: 'JDK-9', publisherStrategy: 'EXPLICIT', options: [junitPublisher(disabled: false)]) {
sh "mvn ${MAVEN_ARGS} verify"
}
}
}

stage('Archive') {
archiveArtifacts artifacts: 'target/*.jar', fingerprint: true
stage('Build Docs') {
steps {
withMaven(maven: 'MVN-3', jdk: 'JDK-9', publisherStrategy: 'EXPLICIT') {
sh "mvn ${MAVEN_ARGS} site"
}
}
}
stage('Post Build Cleanup') {
step($class: 'WsCleanup')
}
post {
always {
cleanWs()
}
}
}
}

0 comments on commit 1f75096

Please sign in to comment.