-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile.release
70 lines (66 loc) · 2.21 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
68
69
70
pipeline {
agent { label 'jenkins-jdk13' }
options { timestamps() }
stages {
stage('Checkout') {
steps {
withCredentials(
[usernamePassword(credentialsId: 'e1f5c9f9-214d-4ba3-85d8-cfdefdf3c97b',
usernameVariable: 'gitUser',
passwordVariable: 'gitPwd'
)]) {
sh "rm -rf target"
sh "git clone https://${gitUser}:${gitPwd}@${gitUrl.split('://')[1]} target"
}
}
}
stage('Build release') {
steps{
dir( path: 'target') {
sh "git config user.email 'development@crowdcode.io'"
sh "git config user.name 'Jenkins Release Job'"
sh "git checkout develop"
mvn("com.amashchenko.maven.plugin:gitflow-maven-plugin:release-start")
mvn("com.amashchenko.maven.plugin:gitflow-maven-plugin:release-finish " + getVersionDigitToIncement())
}
}
}
}
post {
always {
script {
dir( path: 'target') {
sh "git checkout master"
pom = readMavenPom file: 'pom.xml'
addHtmlBadge(html: "<br>release version: ${pom.version}")
}
}
}
}
}
def getVersionDigitToIncement() {
if(params.versionDigitToIncrement == "major") {
return "-DversionDigitToIncrement=0";
} else if(params.versionDigitToIncrement == "minor") {
return "-DversionDigitToIncrement=1";
} else {
return "-DversionDigitToIncrement=2";
}
}
def mvn(param) {
if ( readMavenPom().getVersion().contains("SNAPSHOT") ) {
env.docker_registry = "docker-snapshots.crowdcode.io"
}
else
{
env.docker_registry = "docker-release.crowdcode.io"
}
env.docker_registry_read = "docker-repo.crowdcode.io"
withMaven(
// globalMavenSettingsConfig: 'GlobalSettingsNexus',
options: [openTasksPublisher(disabled: true)],
mavenOpts: '-Xmx1536m -Xms512m',
maven: 'maven-3.6.0') {
sh "mvn -U -B -e ${param}"
}
}