2018-03-13 11:42:39 +01:00
|
|
|
pipeline {
|
|
|
|
agent any
|
|
|
|
tools {
|
|
|
|
maven 'Maven 3'
|
|
|
|
jdk 'OracleJDK 8'
|
|
|
|
}
|
|
|
|
stages {
|
2018-03-13 12:44:54 +01:00
|
|
|
stage ('prepare') {
|
|
|
|
steps {
|
2018-03-13 12:51:59 +01:00
|
|
|
script {
|
|
|
|
env.CI_SKIP = "false"
|
2018-03-13 13:03:48 +01:00
|
|
|
result = sh (script: "git log -1 | grep '(?s).[CI[-\\s]SKIP].*'", returnStatus: true)
|
2018-03-13 12:51:59 +01:00
|
|
|
if (result == 0) {
|
|
|
|
env.CI_SKIP = "true"
|
|
|
|
error "'[CI-SKIP]' found in git commit message. Aborting."
|
|
|
|
}
|
2018-03-13 12:44:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stage ('clean') {
|
2018-03-13 11:42:39 +01:00
|
|
|
steps {
|
|
|
|
echo 'Cleaning the maven workspace...'
|
2018-03-13 13:03:48 +01:00
|
|
|
sh 'mvn clean'
|
2018-03-13 11:42:39 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-13 12:44:54 +01:00
|
|
|
stage ('dependencies') {
|
2018-03-13 11:42:39 +01:00
|
|
|
steps {
|
|
|
|
echo 'Downloading dependencies...'
|
2018-03-13 13:03:48 +01:00
|
|
|
sh 'mvn dependency:go-offline'
|
2018-03-13 11:42:39 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-13 12:44:54 +01:00
|
|
|
stage ('validate') {
|
2018-03-13 11:42:39 +01:00
|
|
|
steps {
|
|
|
|
echo 'Validating the maven project...'
|
2018-03-13 13:03:48 +01:00
|
|
|
sh 'mvn -o validate'
|
2018-03-13 11:42:39 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-13 12:44:54 +01:00
|
|
|
stage ('compile') {
|
2018-03-13 11:42:39 +01:00
|
|
|
steps {
|
|
|
|
echo 'Compiling source classes...'
|
2018-03-13 13:03:48 +01:00
|
|
|
sh 'mvn -o compile'
|
2018-03-13 11:42:39 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-13 12:44:54 +01:00
|
|
|
stage ('compile-test') {
|
2018-03-13 11:42:39 +01:00
|
|
|
steps {
|
|
|
|
echo 'Compiling test classes...'
|
2018-03-13 13:03:48 +01:00
|
|
|
sh 'mvn -o test-compile'
|
2018-03-13 11:42:39 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-13 12:44:54 +01:00
|
|
|
stage ('test') {
|
2018-03-13 11:42:39 +01:00
|
|
|
steps {
|
|
|
|
echo 'Performing unit testing...'
|
2018-03-13 13:03:48 +01:00
|
|
|
sh 'mvn -o test'
|
2018-03-13 11:42:39 +01:00
|
|
|
}
|
|
|
|
post {
|
|
|
|
success {
|
|
|
|
echo 'Archiving test results...'
|
|
|
|
junit 'target/surefire-reports/**/*.xml'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-13 12:44:54 +01:00
|
|
|
stage ('package') {
|
2018-03-13 11:42:39 +01:00
|
|
|
steps {
|
|
|
|
echo 'Preparing the final package...'
|
2018-03-13 13:03:48 +01:00
|
|
|
sh 'mvn -o package'
|
2018-03-13 11:42:39 +01:00
|
|
|
}
|
|
|
|
post {
|
|
|
|
success {
|
|
|
|
echo 'Archiving the final package...'
|
|
|
|
archiveArtifacts artifacts: 'target/*.jar', fingerprint: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-13 12:44:54 +01:00
|
|
|
stage ('sources') {
|
2018-03-13 11:42:39 +01:00
|
|
|
when {
|
|
|
|
branch "master"
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
echo 'Generating sources...'
|
2018-03-13 13:03:48 +01:00
|
|
|
sh 'mvn -o source:jar'
|
2018-03-13 11:42:39 +01:00
|
|
|
}
|
|
|
|
post {
|
|
|
|
success {
|
|
|
|
echo 'Archiving sources...'
|
|
|
|
archiveArtifacts artifacts: 'target/*-souces.jar', fingerprint: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-13 12:44:54 +01:00
|
|
|
stage ('javadoc') {
|
2018-03-13 11:42:39 +01:00
|
|
|
when {
|
|
|
|
branch "master"
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
echo 'Generaing javadocs...'
|
2018-03-13 13:03:48 +01:00
|
|
|
sh 'mvn -o javadoc:javadoc javadoc:jar'
|
2018-03-13 11:42:39 +01:00
|
|
|
}
|
|
|
|
post {
|
|
|
|
success {
|
|
|
|
echo 'Archiving javadocs...'
|
|
|
|
step([
|
|
|
|
$class: 'JavadocArchiver',
|
|
|
|
javadocDir: 'target/site/apidocs',
|
|
|
|
keepAll: true
|
|
|
|
])
|
|
|
|
archiveArtifacts artifacts: 'target/*-javadoc.jar', fingerprint: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-13 12:44:54 +01:00
|
|
|
stage ('verify') {
|
2018-03-13 11:42:39 +01:00
|
|
|
steps {
|
|
|
|
echo 'Performing integration testing...'
|
2018-03-13 13:03:48 +01:00
|
|
|
sh 'mvn -o verify'
|
2018-03-13 11:42:39 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-13 12:44:54 +01:00
|
|
|
stage ('install') {
|
2018-03-13 11:42:39 +01:00
|
|
|
steps {
|
|
|
|
echo 'Installing artifacts to the local repository...'
|
2018-03-13 13:03:48 +01:00
|
|
|
sh 'mvn -o install'
|
2018-03-13 11:42:39 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-13 12:44:54 +01:00
|
|
|
stage ('deploy') {
|
2018-03-13 11:42:39 +01:00
|
|
|
when {
|
|
|
|
branch "master"
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
echo 'Deploying to repository...'
|
2018-03-13 13:03:48 +01:00
|
|
|
sh 'mvn -o deploy'
|
2018-03-13 11:42:39 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-13 12:54:11 +01:00
|
|
|
}
|
|
|
|
post {
|
|
|
|
always {
|
|
|
|
script {
|
|
|
|
if (env.CI_SKIP == "true") {
|
|
|
|
currentBuild.result = 'NOT_BUILT'
|
2018-03-13 12:51:59 +01:00
|
|
|
}
|
2018-03-13 12:44:54 +01:00
|
|
|
}
|
|
|
|
}
|
2018-03-13 11:42:39 +01:00
|
|
|
}
|
|
|
|
}
|