forked from apache/incubator-kie-kogito-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
202 lines (192 loc) · 6.1 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
@Library('jenkins-pipeline-shared-libraries')_
import org.kie.jenkins.MavenCommand
changeAuthor = env.ghprbPullAuthorLogin ?: CHANGE_AUTHOR
changeBranch = env.ghprbSourceBranch ?: CHANGE_BRANCH
changeTarget = env.ghprbTargetBranch ?: CHANGE_TARGET
pipeline {
agent {
label 'kie-rhel7 && kie-mem16g'
}
tools {
maven 'kie-maven-3.6.2'
jdk 'kie-jdk11'
}
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '10', numToKeepStr: '')
timeout(time: 360, unit: 'MINUTES')
}
environment {
MAVEN_OPTS = '-Xms1024m -Xmx4g'
}
stages {
stage('Initialize') {
steps {
checkoutRepo('kogito-runtimes')
checkoutOptaplannerRepo()
checkoutRepo('kogito-apps')
checkoutRepo('kogito-examples')
checkoutRepo('kogito-examples', 'kogito-examples-persistence')
checkoutRepo('kogito-examples', 'kogito-examples-events')
}
}
stage('Build quarkus') {
when {
expression { return getQuarkusBranch() }
}
steps {
script {
checkoutQuarkusRepo()
getMavenCommand('quarkus', false)
.withProperty('quickly')
.run('clean install')
}
}
}
stage('Build Runtimes') {
steps {
script {
getMavenCommand('kogito-runtimes')
.skipTests(true)
.withProperty('skipITs', true)
.run('clean install')
}
}
}
stage('Build Optaplanner') {
steps {
script {
// Skip unnecessary plugins to save time.
getMavenCommand('optaplanner')
.withProperty('quickly')
.run('clean install')
}
}
}
stage('Build kogito-examples') {
steps {
script {
getMavenCommand('kogito-examples', true, true)
.withProperty('validate-formatting')
.run('clean install')
}
}
post {
cleanup {
script {
cleanContainers()
}
}
}
}
stage('Build kogito-examples with persistence') {
steps {
script {
getMavenCommand('kogito-examples-persistence', true, true)
.withProfiles(['persistence'])
.run('clean verify')
}
}
post {
cleanup {
script {
cleanContainers()
}
}
}
}
stage('Build kogito-examples with events') {
steps {
script {
getMavenCommand('kogito-examples-events', true, true)
.withProfiles(['events'])
.run('clean verify')
}
}
post {
cleanup {
script {
cleanContainers()
}
}
}
}
}
post {
always {
script {
junit '**/target/surefire-reports/**/*.xml'
}
}
failure {
script {
mailer.sendEmail_failedPR()
}
}
unstable {
script {
mailer.sendEmail_unstablePR()
}
}
fixed {
script {
mailer.sendEmail_fixedPR()
}
}
cleanup {
script {
util.cleanNode('docker')
}
}
}
}
void checkoutRepo(String repo, String dirName=repo) {
dir(dirName) {
githubscm.checkoutIfExists(repo, changeAuthor, changeBranch, 'kiegroup', changeTarget, true)
}
}
void checkoutQuarkusRepo() {
dir('quarkus') {
checkout(githubscm.resolveRepository('quarkus', 'quarkusio', getQuarkusBranch(), false))
}
}
void checkoutOptaplannerRepo() {
String targetBranch = changeTarget
String [] versionSplit = targetBranch.split("\\.")
if(versionSplit.length == 3
&& versionSplit[0].isNumber()
&& versionSplit[1].isNumber()
&& versionSplit[2] == 'x') {
targetBranch = "${Integer.parseInt(versionSplit[0]) + 7}.${versionSplit[1]}.x"
} else {
echo "Cannot parse changeTarget as release branch so going further with current value: ${changeTarget}"
}
dir('optaplanner') {
githubscm.checkoutIfExists('optaplanner', changeAuthor, changeBranch, 'kiegroup', targetBranch, true)
}
}
MavenCommand getMavenCommand(String directory, boolean addQuarkusVersion=true, boolean canNative = false){
mvnCmd = new MavenCommand(this, ['-fae'])
.withSettingsXmlId('kogito_release_settings')
// add timestamp to Maven logs
.withOptions(['-Dorg.slf4j.simpleLogger.showDateTime=true', '-Dorg.slf4j.simpleLogger.dateTimeFormat=HH:mm:ss,SSS'])
.inDirectory(directory)
if (addQuarkusVersion && getQuarkusBranch()) {
mvnCmd.withProperty('version.io.quarkus', '999-SNAPSHOT')
}
if(canNative && isNative()) {
mvnCmd.withProfiles(['native'])
.withProperty('quarkus.native.container-build', true)
.withProperty('quarkus.native.container-runtime', 'docker')
.withProperty('quarkus.profile', 'native') // Added due to https://github.com/quarkusio/quarkus/issues/13341
}
return mvnCmd
}
void cleanContainers() {
cloud.cleanContainersAndImages('docker')
}
boolean isNative() {
return env['NATIVE'] && env['NATIVE'].toBoolean()
}
String getQuarkusBranch() {
return env['QUARKUS_BRANCH']
}