blob: f18592d3882b05eda08f4e5f44f7a20e479113ed [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.
Romain Grecourtf7e3a482018-11-20 00:47:09 -08003 *
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v. 2.0, which is available at
6 * http://www.eclipse.org/legal/epl-2.0.
7 *
8 * This Source Code may also be made available under the following Secondary
9 * Licenses when the conditions for such availability set forth in the
10 * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11 * version 2 with the GNU Classpath Exception, which is available at
12 * https://www.gnu.org/software/classpath/license.html.
13 *
14 * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15 */
16
Romain Grecourtf7e3a482018-11-20 00:47:09 -080017
18// 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
arjantijms0dea8102020-03-27 22:00:01 +010022// list of test ids
23def jobs = [
hussainnm1f2c0592021-02-23 16:48:38 +053024 "cdi_all",
arjantijmsfd627ea2021-02-26 18:21:41 +010025 "ql_gf_full_profile_all",
arjantijmsbf2bda32021-03-07 12:32:06 +010026 "ql_gf_web_profile_all",
27 "web_jsp"
arjantijms557f8c82020-06-10 00:29:24 +020028]
29
30
31def jobs_all = [
arjantijms0557c802021-02-09 23:22:11 +010032 "cdi_all",
33 "ql_gf_full_profile_all",
34 "ql_gf_web_profile_all",
arjantijms87e21012020-06-10 15:07:23 +020035 "web_jsp",
David Matějčekc5418932021-11-05 22:03:23 +010036
arjantijms0dea8102020-03-27 22:00:01 +010037 "deployment_all",
38 "ejb_group_1",
39 "ejb_group_2",
40 "ejb_group_3",
41 "ejb_web_all",
arjantijms0dea8102020-03-27 22:00:01 +010042 "ql_gf_nucleus_all",
arjantijms0dea8102020-03-27 22:00:01 +010043 "nucleus_admin_all",
44 "jdbc_all",
45 "batch_all",
46 "persistence_all",
47 "connector_group_1",
48 "connector_group_2",
49 "connector_group_3",
50 "connector_group_4"
51]
52
arjantijmsbedfd342020-04-21 19:02:36 +020053def parallelStagesMap = jobs.collectEntries {
54 ["${it}": generateStage(it)]
55}
56
57def generateStage(job) {
58 return {
59 podTemplate(label: env.label) {
60 node(label) {
61 stage("${job}") {
62 container('glassfish-ci') {
63 // do the scm checkout
64 retry(10) {
65 sleep 60
66 checkout scm
67 }
David Matějčekc5418932021-11-05 22:03:23 +010068
arjantijmsbedfd342020-04-21 19:02:36 +020069 // run the test
70 unstash 'build-bundles'
David Matějčekc5418932021-11-05 22:03:23 +010071
arjantijmsbedfd342020-04-21 19:02:36 +020072 try {
73 retry(3) {
74 timeout(time: 2, unit: 'HOURS') {
hs5363e735002020-06-10 10:54:06 +090075 sh """
hs53648024882020-06-03 12:46:06 +090076 export CLASSPATH=$WORKSPACE/glassfish6/javadb
hs53682aa7e92020-06-08 17:52:43 +090077 ./appserver/tests/gftest.sh run_test ${job}
hs5363e735002020-06-10 10:54:06 +090078 """
arjantijmsbedfd342020-04-21 19:02:36 +020079 }
80 }
81 } finally {
82 // archive what we can...
83 archiveArtifacts artifacts: "${job}-results.tar.gz"
84 junit testResults: 'results/junitreports/*.xml', allowEmptyResults: false
85 }
86 }
87 }
88 }
89 }
90 }
91}
92
Romain Grecourtf7e3a482018-11-20 00:47:09 -080093pipeline {
David Matějčekc5418932021-11-05 22:03:23 +010094
Romain Grecourtf7e3a482018-11-20 00:47:09 -080095 options {
96 // keep at most 50 builds
Steve Millidge0b6a70d2020-05-13 21:22:08 +010097 buildDiscarder(logRotator(numToKeepStr: '10'))
David Matějčekc5418932021-11-05 22:03:23 +010098
Romain Grecourtf7e3a482018-11-20 00:47:09 -080099 // preserve the stashes to allow re-running a test stage
100 preserveStashes()
David Matějčekc5418932021-11-05 22:03:23 +0100101
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800102 // issue related to default 'implicit' checkout, disable it
103 skipDefaultCheckout()
David Matějčekc5418932021-11-05 22:03:23 +0100104
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800105 // abort pipeline if previous stage is unstable
106 skipStagesAfterUnstable()
David Matějčekc5418932021-11-05 22:03:23 +0100107
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800108 // show timestamps in logs
109 timestamps()
David Matějčekc5418932021-11-05 22:03:23 +0100110
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800111 // global timeout, abort after 6 hours
112 timeout(time: 6, unit: 'HOURS')
113 }
David Matějčekc5418932021-11-05 22:03:23 +0100114
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800115 agent {
116 kubernetes {
117 label "${env.label}"
118 defaultContainer 'glassfish-ci'
119 yaml """
120apiVersion: v1
121kind: Pod
122metadata:
123spec:
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800124 volumes:
arjantijms937dc552020-01-24 18:41:39 +0100125 - name: "jenkins-home"
126 emptyDir: {}
127 - name: maven-repo-shared-storage
128 persistentVolumeClaim:
129 claimName: glassfish-maven-repo-storage
arjantijms65dd03e2020-01-21 13:37:04 +0100130 - name: settings-xml
131 secret:
132 secretName: m2-secret-dir
133 items:
134 - key: settings.xml
135 path: settings.xml
136 - name: settings-security-xml
137 secret:
138 secretName: m2-secret-dir
139 items:
140 - key: settings-security.xml
141 path: settings-security.xml
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800142 - name: maven-repo-local-storage
143 emptyDir: {}
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800144 containers:
145 - name: jnlp
146 image: jenkins/jnlp-slave:alpine
147 imagePullPolicy: IfNotPresent
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800148 env:
149 - name: JAVA_TOOL_OPTIONS
150 value: -Xmx1G
151 resources:
152 limits:
153 memory: "1Gi"
154 cpu: "1"
155 - name: glassfish-ci
arjantijms64070942020-04-16 22:05:45 +0200156 # Docker image defined in this project in [glassfish]/etc/docker/Dockerfile
hs53673303642021-02-23 14:49:35 +0900157 image: ee4jglassfish/ci:tini-jdk-11.0.10
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800158 args:
159 - cat
160 tty: true
161 imagePullPolicy: Always
162 volumeMounts:
arjantijms64070942020-04-16 22:05:45 +0200163 - name: "jenkins-home"
164 mountPath: "/home/jenkins"
arjantijms937dc552020-01-24 18:41:39 +0100165 readOnly: false
David Matějčekc5418932021-11-05 22:03:23 +0100166 - name: maven-repo-shared-storage
arjantijms64070942020-04-16 22:05:45 +0200167 mountPath: /home/jenkins/.m2/repository
arjantijms65dd03e2020-01-21 13:37:04 +0100168 - name: settings-xml
169 mountPath: /home/jenkins/.m2/settings.xml
170 subPath: settings.xml
171 readOnly: true
172 - name: settings-security-xml
173 mountPath: /home/jenkins/.m2/settings-security.xml
174 subPath: settings-security.xml
175 readOnly: true
arjantijms64070942020-04-16 22:05:45 +0200176 - name: maven-repo-local-storage
177 mountPath: "/home/jenkins/.m2/repository/org/glassfish/main"
arjantijmse93cce92020-01-22 13:42:36 +0100178 env:
179 - name: "MAVEN_OPTS"
180 value: "-Duser.home=/home/jenkins"
181 - name: "MVN_EXTRA"
hs536a269f0c2021-02-26 15:15:21 +0900182 value: "--batch-mode -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800183 resources:
184 limits:
185 memory: "7Gi"
186 cpu: "3"
187"""
188 }
189 }
David Matějčekc5418932021-11-05 22:03:23 +0100190
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800191 environment {
arjantijms3cfb3a32020-02-18 23:13:47 +0100192 S1AS_HOME = "${WORKSPACE}/glassfish6/glassfish"
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800193 APS_HOME = "${WORKSPACE}/appserver/tests/appserv-tests"
194 TEST_RUN_LOG = "${WORKSPACE}/tests-run.log"
195 GF_INTERNAL_ENV = credentials('gf-internal-env')
David Matějčekc5418932021-11-05 22:03:23 +0100196 PORT_ADMIN=4848
197 PORT_HTTP=8080
198 PORT_HTTPS=8181
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800199 }
David Matějčekc5418932021-11-05 22:03:23 +0100200
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800201 stages {
202 stage('build') {
203 agent {
204 kubernetes {
205 label "${env.label}"
206 }
207 }
208 steps {
209 container('glassfish-ci') {
210 timeout(time: 1, unit: 'HOURS') {
David Matějčekc5418932021-11-05 22:03:23 +0100211
arjantijms64070942020-04-16 22:05:45 +0200212 // do the scm checkout
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800213 checkout scm
David Matějčekc5418932021-11-05 22:03:23 +0100214
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800215 // do the build
216 sh '''
arjantijms65dd03e2020-01-21 13:37:04 +0100217 echo Maven version
218 mvn -v
David Matějčekc5418932021-11-05 22:03:23 +0100219
arjantijms64070942020-04-16 22:05:45 +0200220 echo User
221 id
David Matějčekc5418932021-11-05 22:03:23 +0100222
arjantijms64070942020-04-16 22:05:45 +0200223 echo Uname
224 uname -a
David Matějčekc5418932021-11-05 22:03:23 +0100225
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800226 bash -xe ./gfbuild.sh build_re_dev
227 '''
arjantijms5c745c82020-05-19 23:35:15 +0200228 archiveArtifacts artifacts: 'bundles/*.zip'
arjantijmscc4f06a2020-04-29 18:23:40 +0200229 // junit testResults: 'test-results/build-unit-tests/results/junitreports/test_results_junit.xml'
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800230 stash includes: 'bundles/*', name: 'build-bundles'
231 }
232 }
233 }
234 }
David Matějčekc5418932021-11-05 22:03:23 +0100235
hs53648024882020-06-03 12:46:06 +0900236 stage('tests') {
237 steps {
238 script {
239 parallel parallelStagesMap
240 }
241 }
242 }
Romain Grecourtf7e3a482018-11-20 00:47:09 -0800243 }
RohitKumarJain0b5633b2020-02-04 12:14:18 +0000244}
arjantijms64070942020-04-16 22:05:45 +0200245
arjantijms64070942020-04-16 22:05:45 +0200246