-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
64 lines (54 loc) · 1.37 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!groovy
pipeline {
agent any
tools {
maven 'Maven 3.3.9'
}
environment {
IMAGE = readMavenPom().getArtifactId()
POM_VERSION = readMavenPom().getVersion()
BUILD_ID = "${currentBuild.number}"
BUILD_RELEASE_VERSION = readMavenPom().getVersion().replace("-SNAPSHOT", "")
}
stages {
/* Uncomment if using explicit checkout
stage('Checkout') {
steps {
checkout scm
}
}*/
stage('Build') {
steps {
echo "Performing build of ${IMAGE} version ${BUILD_RELEASE_VERSION}.${currentBuild.number} (${POM_VERSION})"
echo "Build id: ${BUILD_ID}"
echo "M2_HOME = ${M2_HOME}"
// Set the version to the Maven version replacing -SNAPSHOT with the build number
sh "mvn versions:set -DnewVersion=${BUILD_RELEASE_VERSION}.${currentBuild.number}"
// Build the application
sh 'mvn install'
// Set the version back to -SNAPSHOT
sh "mvn versions:set -DnewVersion=${POM_VERSION}"
}
post {
success {
archiveArtifacts "target/todo-svc.jar"
}
always {
junit 'target/surefire-reports/**/*.xml'
}
}
}
}
post {
// Always runs. And it runs before any of the other post conditions.
always {
// Clear the workspace
deleteDir()
}
}
// The options directive is for configuration that applies to the whole job.
options {
// Keep 10 last builds only
buildDiscarder(logRotator(numToKeepStr:'10'))
}
}