This repository has been archived by the owner on May 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathJenkinsfile-release
80 lines (70 loc) · 2.66 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
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env groovy
pipeline {
agent {
label 'slave-group-release'
}
parameters {
string(name: 'version', defaultValue: '', description: 'Release version')
string(name: 'nextVersion', defaultValue: '', description: 'Next working version')
booleanParam(name: 'dryRun', defaultValue: false, description: 'If true, we don\'t deploy to nexus')
gitParameter(name: 'branch', defaultValue: 'origin/main', branchFilter: 'origin/(.*)', type: 'PT_BRANCH', description: 'Branch to release from')
}
stages {
stage('Prepare') {
steps {
script {
env.MAVEN_HOME = tool('Maven')
env.MAVEN_OPTS = "-Xmx1g -XX:+HeapDumpOnOutOfMemoryError"
env.JAVA_HOME = tool('JDK 11')
}
}
}
stage('Checkout') {
steps {
checkout scm
}
}
stage('Version') {
steps {
sh "$MAVEN_HOME/bin/mvn -B -V versions:set -DnewVersion=${params.version} -DprocessAllModules=true"
}
}
stage('Deploy') {
when {
expression { !params.dryRun }
}
steps {
configFileProvider([configFile(fileId: 'maven-settings-with-deploy-release', variable: 'MAVEN_SETTINGS')]) {
sh "$MAVEN_HOME/bin/mvn -B -V -s '$MAVEN_SETTINGS' -DskipTests clean deploy"
}
}
}
stage('Tag') {
steps {
sh "$MAVEN_HOME/bin/mvn -B -V scm:checkin -Dmessage=\"Releasing version ${params.version}\" -DpushChanges=false"
sh "$MAVEN_HOME/bin/mvn -B -V scm:tag -Dtag=${params.version}"
}
}
stage('Next version') {
steps {
script {
sh "$MAVEN_HOME/bin/mvn -B -V versions:set -DnewVersion=${params.nextVersion} -DprocessAllModules=true"
sh "$MAVEN_HOME/bin/mvn -B -V -Dmessage='Next version ${params.nextVersion}' -DscmVersion=${params.branch} -DscmVersionType=branch scm:checkin"
}
}
}
}
post {
always {
sh 'git clean -fdx -e "*.hprof" || echo "git clean failed, exit code $?"'
}
failure {
echo "post build status: failure"
emailext to: '${DEFAULT_RECIPIENTS}', subject: '${DEFAULT_SUBJECT}', body: '${DEFAULT_CONTENT}'
}
success {
echo "post build status: success"
emailext to: '${DEFAULT_RECIPIENTS}', subject: '${DEFAULT_SUBJECT}', body: '${DEFAULT_CONTENT}'
}
}
}