-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathjpa-3.2-tck.Jenkinsfile
More file actions
187 lines (185 loc) · 10.1 KB
/
jpa-3.2-tck.Jenkinsfile
File metadata and controls
187 lines (185 loc) · 10.1 KB
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
@Library('hibernate-jenkins-pipeline-helpers') _
// Avoid running the pipeline on branch indexing
if (currentBuild.getBuildCauses().toString().contains('BranchIndexingCause')) {
print "INFO: Build skipped due to trigger being Branch Indexing"
currentBuild.result = 'NOT_BUILT'
return
}
def throttleCount
// Don't build the TCK on PRs, unless they use the tck label
if ( env.CHANGE_ID != null ) {
if ( !pullRequest.labels.contains( 'tck' ) ) {
print "INFO: Build skipped because pull request doesn't have 'tck' label"
return
}
throttleCount = 20
}
else {
throttleCount = 1
}
pipeline {
agent none
tools {
jdk 'OpenJDK 25 Latest'
}
options {
rateLimitBuilds(throttle: [count: throttleCount, durationName: 'day', userBoost: true])
buildDiscarder(logRotator(numToKeepStr: '3', artifactNumToKeepStr: '3'))
disableConcurrentBuilds(abortPrevious: true)
}
parameters {
choice(name: 'IMAGE_JDK', choices: ['jdk17', 'jdk25'], description: 'The JDK base image version to use for the TCK image.')
string(name: 'TCK_VERSION', defaultValue: '3.2.1', description: 'The version of the Jakarta JPA TCK i.e. `2.2.0` or `3.0.1`')
string(name: 'TCK_SHA', defaultValue: '1d282675f43fa13cf8ab2537d6dbfb1e1c95f7b838ab7cdd053e185c363a6519', description: 'The SHA256 of the Jakarta JPA TCK that is distributed under https://download.eclipse.org/jakartaee/persistence/3.1/jakarta-persistence-tck-${TCK_VERSION}.zip.sha256')
string(name: 'TCK_URL', defaultValue: 'https://download.eclipse.org/jakartaee/persistence/3.2/jakarta-persistence-tck-3.2.1.zip', description: 'The URL from which to download the TCK ZIP file. Only needed for testing staged builds. Ensure the TCK_VERSION variable matches the ZIP file name suffix.')
choice(name: 'RDBMS', choices: ['postgresql','mysql','mssql','oracle','db2','sybase'], description: 'The JDK base image version to use for the TCK image.')
}
stages {
stage('Checks') {
steps {
requireApprovalForPullRequest 'hibernate'
}
}
stage('TCK') {
agent {
label 'LongDuration'
}
stages {
stage('Build') {
steps {
dir('hibernate') {
checkout scm
withEnv([
"DISABLE_REMOTE_GRADLE_CACHE=true"
]) {
sh './gradlew clean publishToMavenLocal -x test --no-scan --no-daemon --no-build-cache --stacktrace'
// For some reason, Gradle does not publish hibernate-platform and hibernate-testing
// to the local maven repository with the previous command,
// but requires an extra run instead
sh './gradlew :hibernate-testing:publishToMavenLocal :hibernate-platform:publishToMavenLocal -x test --no-scan --no-daemon --no-build-cache --stacktrace'
}
script {
env.HIBERNATE_VERSION = sh (
script: "grep hibernateVersion gradle/version.properties|cut -d'=' -f2",
returnStdout: true
).trim()
switch (params.RDBMS) {
case "mysql":
docker.image('mysql:8.2.0').pull()
sh "./docker_db.sh mysql"
break;
case "mssql":
docker.image('mcr.microsoft.com/mssql/server@sha256:5439be9edc3b514cf647bcd3651779fa13f487735a985f40cbdcfecc60fea273').pull()
sh "./docker_db.sh mssql"
break;
case "oracle":
docker.image('gvenzl/oracle-free:23').pull()
sh "./docker_db.sh oracle"
break;
case "postgresql":
docker.image('postgis/postgis:16-3.4').pull()
sh "./docker_db.sh postgresql"
break;
case "db2":
docker.image('icr.io/db2_community/db2:11.5.9.0').pull()
sh "./docker_db.sh db2"
break;
case "sybase":
docker.image('nguoianphu/docker-sybase').pull()
sh "./docker_db.sh sybase"
break;
}
}
}
dir('tck') {
checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/hibernate/jakarta-tck-runner.git']]]
script {
withCredentials([file(credentialsId: 'sybase-jconnect-driver', variable: 'jconnect_driver')]) {
sh 'cp -f $jconnect_driver ./jpa-3.2/jconn42.jar'
if ( params.TCK_URL == null || params.TCK_URL.isEmpty() ) {
sh "cd jpa-3.2; docker build -f Dockerfile.${params.IMAGE_JDK} -t jakarta-tck-runner --build-arg TCK_VERSION=${params.TCK_VERSION} --build-arg TCK_SHA=${params.TCK_SHA} ."
}
else {
sh "cd jpa-3.2; docker build -f Dockerfile.${params.IMAGE_JDK} -t jakarta-tck-runner --build-arg TCK_VERSION=${params.TCK_VERSION} --build-arg TCK_SHA=${params.TCK_SHA} --build-arg 'TCK_URL=${params.TCK_URL}' ."
}
}
}
}
}
}
stage('Run TCK') {
steps {
script {
def containerName
if ( params.RDBMS == 'postgresql' ) {
containerName = 'postgres'
}
else {
containerName = params.RDBMS
}
def dockerRunOptions = "--network=tck-net -e DB_HOST=${containerName}"
sh """ \
while IFS= read -r container; do
docker network disconnect tck-net \$container || true
done <<< \$(docker network inspect tck-net --format '{{range \$k, \$v := .Containers}}{{print \$k}}{{end}}' 2>/dev/null || true)
docker network rm -f tck-net
docker network create tck-net
docker network connect tck-net ${containerName}
"""
sh """ \
rm -Rf ./results
docker rm -f tck || true
docker run -v ~/.m2/repository:/home/jenkins/.m2/repository:z ${dockerRunOptions} -e MAVEN_OPTS=-Dmaven.repo.local=/home/jenkins/.m2/repository -e RDBMS=${params.RDBMS} -e HIBERNATE_VERSION=$HIBERNATE_VERSION --name tck jakarta-tck-runner || true
docker cp tck:/tck/persistence-tck/bin/target/failsafe-reports ./results
docker cp tck:/tck/persistence-tck/bin/target/test-reports ./results
"""
}
archiveArtifacts artifacts: 'results/**'
script {
def failures = sh (
script: """ \
while read line; do
if [[ "\$line" = *'-error" style="display:none;">' ]]; then
prefix1='<tr class="a" id="'
prefix2='<tr class="b" id="'
suffix='-error" style="display:none;">'
line=\${line#"\$prefix1"}
line=\${line#"\$prefix2"}
test=\${line%"\$suffix"}
echo "\$test"
fi
done <results/test-reports/failsafe-report.html
""",
returnStdout: true
).trim()
if ( !failures.isEmpty() ) {
echo "Some TCK tests failed:"
echo failures
currentBuild.result = 'FAILURE'
}
}
}
}
}
post {
always {
script {
def containerName
if ( params.RDBMS == 'postgresql' ) {
containerName = 'postgres'
}
else {
containerName = params.RDBMS
}
sh "docker rm -f ${containerName}"
}
}
}
}
}
post {
always {
notifyBuildResult maintainers: "andrea@hibernate.org steve@hibernate.org christian.beikov@gmail.com mbellade@redhat.com"
}
}
}