-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
122 lines (111 loc) · 3.88 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* Copyright (C) 2019 DV Bern AG, Switzerland
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
@Library('dvbern-ci') _
properties([
disableConcurrentBuilds(),
[$class: 'BuildDiscarderProperty', strategy: [$class: 'LogRotator', numToKeepStr: '10']],
[
$class : 'GithubProjectProperty',
displayName : '',
projectUrlStr: 'https://github.com/dvbern/kibon-exchange-api-commons/'
],
parameters([
booleanParam(defaultValue: false, description: 'Do you want to perform a Release?', name:
'performRelease'),
string(defaultValue: '', description: 'This release version', name: 'releaseversion', trim:
true),
string(defaultValue: '', description: 'The next release version', name: 'nextreleaseversion',
trim: true)
])
])
def jdkVersion = "Temurin_jdk-17.0.1+12"
// comma separated list of email addresses of all team members (for notification)
def recipients = "[email protected]"
def masterBranchName = "master"
def developBranchName = "develop"
def featureBranchPrefix = "feature"
def releaseBranchPrefix = "release"
def hotfixBranchPrefix = "hotfix"
if (params.performRelease) {
// see https://issues.jenkins-ci.org/browse/JENKINS-53512
def releaseVersion = params.releaseversion
def nextReleaseVersion = params.nextreleaseversion
def credentials = "jenkins-github-token"
dvbJGitFlowRelease {
releaseversion = releaseVersion
nextreleaseversion = nextReleaseVersion
emailRecipients = recipients
credentialsId = credentials
}
} else {
node {
stage('Checkout') {
checkout([
$class : 'GitSCM',
branches : scm.branches,
extensions : scm.extensions + [[$class: 'LocalBranch', localBranch: '']],
userRemoteConfigs: scm.userRemoteConfigs
])
}
String branch = env.BRANCH_NAME.toString()
currentBuild.displayName = "${branch}-${dvbMaven.pomVersion()}-${env.BUILD_NUMBER}"
stage('Maven build') {
def handleFailures = {error ->
if (branch.startsWith(featureBranchPrefix)) {
// feature branche failures should only notify the feature owner
step([
$class : 'Mailer',
notifyEveryUnstableBuild: true,
recipients : emailextrecipients([[$class: 'RequesterRecipientProvider']]),
sendToIndividuals : true])
} else {
dvbErrorHandling.sendMail(recipients, currentBuild, error)
}
}
// in develop and master branches attempt to deploy the artifacts, otherwise only run to the verify phase.
def verifyOrDeploy = {
return (branch.startsWith(masterBranchName) || branch.startsWith(developBranchName)) ?
"deploy" :
"verify"
}
try {
withCredentials([
usernamePassword(
credentialsId: 'schema-registry-credentials',
passwordVariable: 'SCHEMA_REGISTRY_PW',
usernameVariable: 'SCHEMA_REGISTRY_USER'),
usernamePassword(
credentialsId: 'schema-registry-uris',
passwordVariable: 'BASE_URIS',
usernameVariable: 'BASE_URI_DEV')
]) {
withMaven(jdk: jdkVersion) {
dvbUtil.genericSh './mvnw -U -Pdvbern.oss -Dmaven.test.failure.ignore=true clean ' +
verifyOrDeploy()
}
if (currentBuild.result == "UNSTABLE") {
handleFailures("build is unstable")
}
}
} catch (Exception e) {
currentBuild.result = "FAILURE"
handleFailures(e)
throw e
}
}
}
}