blob: 7a4007eed98b0083cd4589ba2fa568ec447e4605 [file] [log] [blame]
Romain Grecourtf7e3a482018-11-20 00:47:09 -08001/*
arjantijmsb4393712021-02-18 23:07:08 +01002 * Copyright (c) 2018-2021 Oracle and/or its affiliates. All rights reserved.
David Matějčeked31d8c2022-01-23 21:53:12 +01003 * Copyright (c) 2022 Contributors to the Eclipse Foundation
Romain Grecourtf7e3a482018-11-20 00:47:09 -08004 *
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v. 2.0, which is available at
7 * http://www.eclipse.org/legal/epl-2.0.
8 *
9 * This Source Code may also be made available under the following Secondary
10 * Licenses when the conditions for such availability set forth in the
11 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
12 * version 2 with the GNU Classpath Exception, which is available at
13 * https://www.gnu.org/software/classpath/license.html.
14 *
15 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16 */
17
Romain Grecourtf7e3a482018-11-20 00:47:09 -080018// the label is unique and identifies the pod descriptor and its resulting pods
19// without this, the agent could be using a pod created from a different descriptor
20env.label = "glassfish-ci-pod-${UUID.randomUUID().toString()}"
21
David Matějčekb19a6f22022-03-31 22:21:42 +020022// Docker images defined in this project in [glassfish]/etc/docker*
23// Older image
24env.gfImage11 = "dmatej/eclipse-jenkins-glassfish:11.0.14.1"
25// Image required to be able to build hibernate-validator snapshot, but now used for glassfish too
26env.gfImage17 = "dmatej/eclipse-jenkins-glassfish:17.20"
David Matějček8c4e7522022-01-27 19:20:11 +010027
arjantijms0dea8102020-03-27 22:00:01 +010028def jobs = [
David Matějček8c4e7522022-01-27 19:20:11 +010029 "verifyPhase",
arjantijms0557c802021-02-09 23:22:11 +010030 "cdi_all",
31 "ql_gf_full_profile_all",
32 "ql_gf_web_profile_all",
arjantijms87e21012020-06-10 15:07:23 +020033 "web_jsp",
arjantijms0dea8102020-03-27 22:00:01 +010034 "ejb_group_1",
35 "ejb_group_2",
36 "ejb_group_3",
David Matějček5cbf9912022-02-07 17:06:55 +010037 "ejb_group_embedded",
38 "batch_all",
39 "connector_group_1",
40 "connector_group_2",
41 "connector_group_3",
42 "connector_group_4",
David Matějčekec4277e2022-02-08 13:02:13 +010043 "jdbc_all",
David Matějčekff68d392022-03-03 22:53:04 +010044 "persistence_all",
45 "naming_all",
46 "deployment_all",
47 "security_all",
48 "webservice_all"
arjantijms0dea8102020-03-27 22:00:01 +010049]
50
arjantijmsbedfd342020-04-21 19:02:36 +020051def parallelStagesMap = jobs.collectEntries {
52 ["${it}": generateStage(it)]
53}
54
55def generateStage(job) {
David Matějček8c4e7522022-01-27 19:20:11 +010056 if (job == 'verifyPhase') {
57 return generateMvnPodTemplate(job)
58 } else {
59 return generateAntPodTemplate(job)
60 }
61}
David Matějčekc5418932021-11-05 22:03:23 +010062
David Matějček8c4e7522022-01-27 19:20:11 +010063def generateMvnPodTemplate(job) {
64 return {
65 podTemplate(
66 inheritFrom: "${env.label}",
67 containers: [
68 containerTemplate(
69 name: "glassfish-build",
David Matějčekb19a6f22022-03-31 22:21:42 +020070 image: "${env.gfImage17}",
David Matějček8c4e7522022-01-27 19:20:11 +010071 resourceRequestMemory: "7Gi",
72 resourceRequestCpu: "2650m"
73 )
74 ]
75 ) {
76 node(label) {
77 stage("${job}") {
78 container('glassfish-build') {
79 retry(5) {
80 sleep 1
81 checkout scm
arjantijmsbedfd342020-04-21 19:02:36 +020082 }
David Matějček8c4e7522022-01-27 19:20:11 +010083 timeout(time: 1, unit: 'HOURS') {
84 sh """
85 mvn clean install
86 """
87 junit testResults: '**/*-reports/*.xml', allowEmptyResults: false
88 }
89 }
arjantijmsbedfd342020-04-21 19:02:36 +020090 }
David Matějček8c4e7522022-01-27 19:20:11 +010091 }
arjantijmsbedfd342020-04-21 19:02:36 +020092 }
David Matějček8c4e7522022-01-27 19:20:11 +010093 }
94}
95
96def generateAntPodTemplate(job) {
97 return {
98 podTemplate(
99 inheritFrom: "${env.label}",
100 containers: [
101 containerTemplate(
102 name: "glassfish-build",
David Matějčekb19a6f22022-03-31 22:21:42 +0200103 image: "${env.gfImage17}",
David Matějček8c4e7522022-01-27 19:20:11 +0100104 resourceRequestMemory: "4Gi",
105 resourceRequestCpu: "2650m"
106 )
107 ]
108 ) {
109 node(label) {
110 stage("${job}") {
111 container('glassfish-build') {
David Matějček8c4e7522022-01-27 19:20:11 +0100112 unstash 'build-bundles'
David Matějček4b821942022-02-10 18:20:04 +0100113 sh """
114 mkdir -p ${WORKSPACE}/appserver/tests
115 tar -xzf ${WORKSPACE}/bundles/appserv_tests.tar.gz -C ${WORKSPACE}/appserver/tests
116 """
David Matějček8c4e7522022-01-27 19:20:11 +0100117 try {
118 timeout(time: 1, unit: 'HOURS') {
119 sh """
David Matějčekee3705b2022-02-16 10:36:40 +0100120 export CLASSPATH=${WORKSPACE}/glassfish7/javadb
David Matějček4b821942022-02-10 18:20:04 +0100121 ${WORKSPACE}/appserver/tests/gftest.sh run_test ${job}
David Matějček8c4e7522022-01-27 19:20:11 +0100122 """
123 }
124 } finally {
125 archiveArtifacts artifacts: "${job}-results.tar.gz"
126 junit testResults: 'results/junitreports/*.xml', allowEmptyResults: false
127 }
128 }
129 }
130 }
131 }
132 }
arjantijmsbedfd342020-04-21 19:02:36 +0200133}
134
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800135pipeline {
David Matějčekc5418932021-11-05 22:03:23 +0100136
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800137 agent {
138 kubernetes {
139 label "${env.label}"
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800140 yaml """
141apiVersion: v1
142kind: Pod
143metadata:
144spec:
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800145 containers:
146 - name: jnlp
David Matějček8c4e7522022-01-27 19:20:11 +0100147 image: jenkins/inbound-agent:4.11-1-alpine-jdk11
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800148 imagePullPolicy: IfNotPresent
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800149 env:
150 - name: JAVA_TOOL_OPTIONS
David Matějček8c4e7522022-01-27 19:20:11 +0100151 value: "-Xmx768m -Xss768k"
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800152 resources:
David Matějček8c4e7522022-01-27 19:20:11 +0100153 # fixes random failure: minimum cpu usage per Pod is 200m, but request is 100m.
154 # affects performance on large repositories
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800155 limits:
David Matějček8c4e7522022-01-27 19:20:11 +0100156 memory: "1200Mi"
157 cpu: "300m"
158 requests:
159 memory: "1200Mi"
160 cpu: "300m"
161 - name: glassfish-build
David Matějčekb19a6f22022-03-31 22:21:42 +0200162 image: ${env.gfImage17}
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800163 args:
164 - cat
165 tty: true
166 imagePullPolicy: Always
167 volumeMounts:
arjantijms64070942020-04-16 22:05:45 +0200168 - name: "jenkins-home"
169 mountPath: "/home/jenkins"
arjantijms937dc552020-01-24 18:41:39 +0100170 readOnly: false
David Matějčekc5418932021-11-05 22:03:23 +0100171 - name: maven-repo-shared-storage
arjantijms64070942020-04-16 22:05:45 +0200172 mountPath: /home/jenkins/.m2/repository
arjantijms65dd03e2020-01-21 13:37:04 +0100173 - name: settings-xml
174 mountPath: /home/jenkins/.m2/settings.xml
175 subPath: settings.xml
176 readOnly: true
177 - name: settings-security-xml
178 mountPath: /home/jenkins/.m2/settings-security.xml
179 subPath: settings-security.xml
180 readOnly: true
arjantijms64070942020-04-16 22:05:45 +0200181 - name: maven-repo-local-storage
182 mountPath: "/home/jenkins/.m2/repository/org/glassfish/main"
arjantijmse93cce92020-01-22 13:42:36 +0100183 env:
184 - name: "MAVEN_OPTS"
David Matějček8c4e7522022-01-27 19:20:11 +0100185 value: "-Duser.home=/home/jenkins -Xmx2500m -Xss768k -XX:+UseStringDeduplication"
arjantijmse93cce92020-01-22 13:42:36 +0100186 - name: "MVN_EXTRA"
hs536a269f0c2021-02-26 15:15:21 +0900187 value: "--batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
David Matějček8c4e7522022-01-27 19:20:11 +0100188 - name: JAVA_TOOL_OPTIONS
189 value: "-Xmx2g -Xss768k -XX:+UseStringDeduplication"
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800190 resources:
191 limits:
David Matějček8c4e7522022-01-27 19:20:11 +0100192 memory: "12Gi"
193 cpu: "8000m"
194 requests:
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800195 memory: "7Gi"
David Matějček8c4e7522022-01-27 19:20:11 +0100196 cpu: "4000m"
197 volumes:
198 - name: "jenkins-home"
199 emptyDir: {}
200 - name: maven-repo-shared-storage
201 persistentVolumeClaim:
202 claimName: glassfish-maven-repo-storage
203 - name: settings-xml
204 secret:
205 secretName: m2-secret-dir
206 items:
207 - key: settings.xml
208 path: settings.xml
209 - name: settings-security-xml
210 secret:
211 secretName: m2-secret-dir
212 items:
213 - key: settings-security.xml
214 path: settings-security.xml
215 - name: maven-repo-local-storage
216 emptyDir: {}
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800217"""
218 }
219 }
David Matějčekc5418932021-11-05 22:03:23 +0100220
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800221 environment {
David Matějček8e6ce042021-11-28 19:18:12 +0100222 S1AS_HOME = "${WORKSPACE}/glassfish7/glassfish"
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800223 APS_HOME = "${WORKSPACE}/appserver/tests/appserv-tests"
224 TEST_RUN_LOG = "${WORKSPACE}/tests-run.log"
225 GF_INTERNAL_ENV = credentials('gf-internal-env')
David Matějčekc5418932021-11-05 22:03:23 +0100226 PORT_ADMIN=4848
227 PORT_HTTP=8080
228 PORT_HTTPS=8181
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800229 }
David Matějčekc5418932021-11-05 22:03:23 +0100230
David Matějček8c4e7522022-01-27 19:20:11 +0100231 options {
232 buildDiscarder(logRotator(numToKeepStr: '10'))
233
234 // to allow re-running a test stage
235 preserveStashes()
236
237 // issue related to default 'implicit' checkout, disable it
238 skipDefaultCheckout()
239
240 // abort pipeline if previous stage is unstable
241 skipStagesAfterUnstable()
242
243 // show timestamps in logs
244 timestamps()
245
246 // global timeout, abort after 6 hours
247 timeout(time: 6, unit: 'HOURS')
248 }
249
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800250 stages {
David Matějček8c4e7522022-01-27 19:20:11 +0100251
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800252 stage('build') {
253 agent {
254 kubernetes {
255 label "${env.label}"
256 }
257 }
258 steps {
David Matějček8c4e7522022-01-27 19:20:11 +0100259 container('glassfish-build') {
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800260 timeout(time: 1, unit: 'HOURS') {
261 checkout scm
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800262 sh '''
arjantijms65dd03e2020-01-21 13:37:04 +0100263 echo Maven version
264 mvn -v
David Matějčekc5418932021-11-05 22:03:23 +0100265
arjantijms64070942020-04-16 22:05:45 +0200266 echo User
267 id
David Matějčekc5418932021-11-05 22:03:23 +0100268
arjantijms64070942020-04-16 22:05:45 +0200269 echo Uname
270 uname -a
David Matějčekc5418932021-11-05 22:03:23 +0100271
David Matějčekda07c942022-02-16 13:59:11 +0100272 # temporary build of external snapshot dependencies
David Matějčekb50d5b12022-03-16 14:03:47 +0100273 mvn clean install -f ./snapshots/pom.xml
David Matějček8c4e7522022-01-27 19:20:11 +0100274 # Until we fix ANTLR in cmp-support-sqlstore, broken in parallel builds. Just -Pfast after the fix.
275 mvn clean install -Pfastest,staging -T4C
276 ./gfbuild.sh archive_bundles
David Matějček4b821942022-02-10 18:20:04 +0100277 mvn clean
278 tar -c -C ${WORKSPACE}/appserver/tests common_test.sh gftest.sh appserv-tests quicklook | gzip --fast > ${WORKSPACE}/bundles/appserv_tests.tar.gz
279 ls -la ${WORKSPACE}/bundles
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800280 '''
arjantijms5c745c82020-05-19 23:35:15 +0200281 archiveArtifacts artifacts: 'bundles/*.zip'
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800282 stash includes: 'bundles/*', name: 'build-bundles'
283 }
284 }
285 }
286 }
David Matějčekc5418932021-11-05 22:03:23 +0100287
hs53648024882020-06-03 12:46:06 +0900288 stage('tests') {
289 steps {
290 script {
291 parallel parallelStagesMap
292 }
293 }
294 }
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800295 }
RohitKumarJain0b5633b2020-02-04 12:14:18 +0000296}
arjantijms64070942020-04-16 22:05:45 +0200297
arjantijms64070942020-04-16 22:05:45 +0200298