-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.release
67 lines (63 loc) · 2.13 KB
/
Jenkinsfile.release
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
65
66
67
pipeline {
agent any
options { timestamps() }
stages {
stage('Checkout') {
steps {
withCredentials(
[usernamePassword(credentialsId: 'gorefest',
usernameVariable: 'gitUser',
passwordVariable: 'gitPwd'
)]) {
sh "rm -rf target"
sh "git clone https://${gitUser}:${gitPwd}@${gitUrl.split('://')[1]} target"
}
}
}
stage('Build release') {
steps{
script {
dir( path: 'target') {
sh "git config user.email '[email protected]'"
sh "git config user.name 'Jenkins Release Job'"
sh "git checkout develop"
mvn("com.amashchenko.maven.plugin:gitflow-maven-plugin:release-start " + getVersionDigitToIncrement())
pom = readMavenPom file: 'pom.xml'
mvn("com.amashchenko.maven.plugin:gitflow-maven-plugin:release-finish")
pom = readMavenPom file: 'pom.xml'
sh "git push"
}
}
}
}
}
post {
always {
script {
dir( path: 'target') {
sh "git checkout master"
pom = readMavenPom file: 'pom.xml'
addHtmlBadge(html: "<br>release version: ${pom.version}")
}
}
}
}
}
def getVersionDigitToIncrement() {
if(params.versionDigitToIncrement == "major") {
return "-DversionDigitToIncrement=0";
} else if(params.versionDigitToIncrement == "minor") {
return "-DversionDigitToIncrement=1";
} else {
return "-DversionDigitToIncrement=2";
}
}
def mvn(param) {
withMaven(
// globalMavenSettingsConfig: 'GlobalSettingsNexus',
options: [openTasksPublisher(disabled: true)],
mavenOpts: '-Xmx1536m -Xms512m',
maven: 'maven-3.6.3') {
sh "mvn -U -B -e ${param}"
}
}