-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjenkinsFile
More file actions
34 lines (27 loc) · 1003 Bytes
/
Copy pathjenkinsFile
File metadata and controls
34 lines (27 loc) · 1003 Bytes
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
node {
def branchVersion = ""
stage ('Checkout') {
// checkout repository
checkout scm
// checkout input branch
sh "git checkout ${caller.env.BRANCH_NAME}"
}
stage ('Determine Branch Version') {
// add maven to path
env.PATH = "${tool 'M3'}/bin:${env.PATH}"
// determine version in pom.xml
def pomVersion = sh(script: 'mvn -q -Dexec.executable=\'echo\' -Dexec.args=\'${project.version}\' --non-recursive exec:exec', returnStdout: true).trim()
// compute proper branch SNAPSHOT version
pomVersion = pomVersion.replaceAll(/-SNAPSHOT/, "")
branchVersion = env.BRANCH_NAME
branchVersion = branchVersion.replaceAll(/origin\//, "")
branchVersion = branchVersion.replaceAll(/\W/, "-")
branchVersion = "${pomVersion}-${branchVersion}-SNAPSHOT"
// set branch SNAPSHOT version in pom.xml
sh "mvn versions:set -DnewVersion=${branchVersion}"
}
stage ('Java Build') {
// build .war package
sh 'mvn clean package -U'
}
}