Skip to content

Commit aecb175

Browse files
committed
Add approval for TCK run
And move Jenkins "input" steps outside of nodes/agents, so that we don't keep a node reserved while we're waiting for input. See best practice 6 in https://www.cloudbees.com/blog/top-10-best-practices-jenkins-pipeline-plugin
1 parent addd80a commit aecb175

File tree

1 file changed

+139
-129
lines changed

1 file changed

+139
-129
lines changed

ci/jpa-3.2-tck.Jenkinsfile

Lines changed: 139 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ else {
2020
}
2121

2222
pipeline {
23-
agent {
24-
label 'LongDuration'
25-
}
23+
agent none
2624
tools {
2725
jdk 'OpenJDK 17 Latest'
2826
}
@@ -39,133 +37,145 @@ pipeline {
3937
choice(name: 'RDBMS', choices: ['postgresql','mysql','mssql','oracle','db2','sybase'], description: 'The JDK base image version to use for the TCK image.')
4038
}
4139
stages {
42-
stage('Build') {
40+
stage('Checks') {
4341
steps {
44-
script {
45-
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
46-
docker.image('openjdk:17-jdk').pull()
47-
}
48-
}
49-
dir('hibernate') {
50-
checkout scm
51-
withEnv([
52-
"DISABLE_REMOTE_GRADLE_CACHE=true"
53-
]) {
54-
sh './gradlew clean publishToMavenLocal -x test --no-scan --no-daemon --no-build-cache --stacktrace -PmavenMirror=nexus-load-balancer-c4cf05fd92f43ef8.elb.us-east-1.amazonaws.com'
55-
// For some reason, Gradle does not publish hibernate-platform and hibernate-testing
56-
// to the local maven repository with the previous command,
57-
// but requires an extra run instead
58-
sh './gradlew :hibernate-testing:publishToMavenLocal :hibernate-platform:publishToMavenLocal -x test --no-scan --no-daemon --no-build-cache --stacktrace -PmavenMirror=nexus-load-balancer-c4cf05fd92f43ef8.elb.us-east-1.amazonaws.com'
59-
}
60-
script {
61-
env.HIBERNATE_VERSION = sh (
62-
script: "grep hibernateVersion gradle/version.properties|cut -d'=' -f2",
63-
returnStdout: true
64-
).trim()
65-
switch (params.RDBMS) {
66-
case "mysql":
67-
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
68-
docker.image('mysql:8.2.0').pull()
69-
}
70-
sh "./docker_db.sh mysql"
71-
break;
72-
case "mssql":
73-
docker.image('mcr.microsoft.com/mssql/server@sha256:5439be9edc3b514cf647bcd3651779fa13f487735a985f40cbdcfecc60fea273').pull()
74-
sh "./docker_db.sh mssql"
75-
break;
76-
case "oracle":
77-
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
78-
docker.image('gvenzl/oracle-free:23').pull()
79-
}
80-
sh "./docker_db.sh oracle"
81-
break;
82-
case "postgresql":
83-
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
84-
docker.image('postgis/postgis:16-3.4').pull()
85-
}
86-
sh "./docker_db.sh postgresql"
87-
break;
88-
case "db2":
89-
docker.image('icr.io/db2_community/db2:11.5.9.0').pull()
90-
sh "./docker_db.sh db2"
91-
break;
92-
case "sybase":
93-
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
94-
docker.image('nguoianphu/docker-sybase').pull()
95-
}
96-
sh "./docker_db.sh sybase"
97-
break;
98-
}
99-
}
100-
}
101-
dir('tck') {
102-
checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/hibernate/jakarta-tck-runner.git']]]
103-
script {
104-
withCredentials([file(credentialsId: 'sybase-jconnect-driver', variable: 'jconnect_driver')]) {
105-
sh 'cp -f $jconnect_driver ./jpa-3.2/jconn42.jar'
106-
if ( params.TCK_URL == null || params.TCK_URL.isEmpty() ) {
107-
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} ."
108-
}
109-
else {
110-
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}' ."
111-
}
112-
}
113-
}
114-
}
115-
}
116-
}
117-
stage('Run TCK') {
118-
steps {
119-
script {
120-
def containerName
121-
if ( params.RDBMS == 'postgresql' ) {
122-
containerName = 'postgres'
123-
}
124-
else {
125-
containerName = params.RDBMS
126-
}
127-
def dockerRunOptions = "--network=tck-net -e DB_HOST=${containerName}"
128-
sh """ \
129-
while IFS= read -r container; do
130-
docker network disconnect tck-net \$container || true
131-
done <<< \$(docker network inspect tck-net --format '{{range \$k, \$v := .Containers}}{{print \$k}}{{end}}' 2>/dev/null || true)
132-
docker network rm -f tck-net
133-
docker network create tck-net
134-
docker network connect tck-net ${containerName}
135-
"""
136-
sh """ \
137-
rm -Rf ./results
138-
docker rm -f tck || true
139-
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
140-
docker cp tck:/tck/persistence-tck/bin/target/failsafe-reports ./results
141-
docker cp tck:/tck/persistence-tck/bin/target/test-reports ./results
142-
"""
143-
}
144-
archiveArtifacts artifacts: 'results/**'
145-
script {
146-
failures = sh (
147-
script: """ \
148-
while read line; do
149-
if [[ "\$line" = *'-error" style="display:none;">' ]]; then
150-
prefix1='<tr class="a" id="'
151-
prefix2='<tr class="b" id="'
152-
suffix='-error" style="display:none;">'
153-
line=\${line#"\$prefix1"}
154-
line=\${line#"\$prefix2"}
155-
test=\${line%"\$suffix"}
156-
echo "\$test"
157-
fi
158-
done <results/test-reports/failsafe-report.html
159-
""",
160-
returnStdout: true
161-
).trim()
162-
if ( !failures.isEmpty() ) {
163-
echo "Some TCK tests failed:"
164-
echo failures
165-
currentBuild.result = 'FAILURE'
166-
}
167-
}
168-
}
42+
requireApprovalForPullRequest 'hibernate'
43+
}
44+
}
45+
stage('TCK') {
46+
agent {
47+
label 'LongDuration'
48+
}
49+
stages {
50+
stage('Build') {
51+
steps {
52+
script {
53+
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
54+
docker.image('openjdk:17-jdk').pull()
55+
}
56+
}
57+
dir('hibernate') {
58+
checkout scm
59+
withEnv([
60+
"DISABLE_REMOTE_GRADLE_CACHE=true"
61+
]) {
62+
sh './gradlew clean publishToMavenLocal -x test --no-scan --no-daemon --no-build-cache --stacktrace -PmavenMirror=nexus-load-balancer-c4cf05fd92f43ef8.elb.us-east-1.amazonaws.com'
63+
// For some reason, Gradle does not publish hibernate-platform and hibernate-testing
64+
// to the local maven repository with the previous command,
65+
// but requires an extra run instead
66+
sh './gradlew :hibernate-testing:publishToMavenLocal :hibernate-platform:publishToMavenLocal -x test --no-scan --no-daemon --no-build-cache --stacktrace -PmavenMirror=nexus-load-balancer-c4cf05fd92f43ef8.elb.us-east-1.amazonaws.com'
67+
}
68+
script {
69+
env.HIBERNATE_VERSION = sh (
70+
script: "grep hibernateVersion gradle/version.properties|cut -d'=' -f2",
71+
returnStdout: true
72+
).trim()
73+
switch (params.RDBMS) {
74+
case "mysql":
75+
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
76+
docker.image('mysql:8.2.0').pull()
77+
}
78+
sh "./docker_db.sh mysql"
79+
break;
80+
case "mssql":
81+
docker.image('mcr.microsoft.com/mssql/server@sha256:5439be9edc3b514cf647bcd3651779fa13f487735a985f40cbdcfecc60fea273').pull()
82+
sh "./docker_db.sh mssql"
83+
break;
84+
case "oracle":
85+
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
86+
docker.image('gvenzl/oracle-free:23').pull()
87+
}
88+
sh "./docker_db.sh oracle"
89+
break;
90+
case "postgresql":
91+
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
92+
docker.image('postgis/postgis:16-3.4').pull()
93+
}
94+
sh "./docker_db.sh postgresql"
95+
break;
96+
case "db2":
97+
docker.image('icr.io/db2_community/db2:11.5.9.0').pull()
98+
sh "./docker_db.sh db2"
99+
break;
100+
case "sybase":
101+
docker.withRegistry('https://index.docker.io/v1/', 'hibernateci.hub.docker.com') {
102+
docker.image('nguoianphu/docker-sybase').pull()
103+
}
104+
sh "./docker_db.sh sybase"
105+
break;
106+
}
107+
}
108+
}
109+
dir('tck') {
110+
checkout changelog: false, poll: false, scm: [$class: 'GitSCM', branches: [[name: '*/main']], extensions: [], userRemoteConfigs: [[url: 'https://github.com/hibernate/jakarta-tck-runner.git']]]
111+
script {
112+
withCredentials([file(credentialsId: 'sybase-jconnect-driver', variable: 'jconnect_driver')]) {
113+
sh 'cp -f $jconnect_driver ./jpa-3.2/jconn42.jar'
114+
if ( params.TCK_URL == null || params.TCK_URL.isEmpty() ) {
115+
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} ."
116+
}
117+
else {
118+
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}' ."
119+
}
120+
}
121+
}
122+
}
123+
}
124+
}
125+
stage('Run TCK') {
126+
steps {
127+
script {
128+
def containerName
129+
if ( params.RDBMS == 'postgresql' ) {
130+
containerName = 'postgres'
131+
}
132+
else {
133+
containerName = params.RDBMS
134+
}
135+
def dockerRunOptions = "--network=tck-net -e DB_HOST=${containerName}"
136+
sh """ \
137+
while IFS= read -r container; do
138+
docker network disconnect tck-net \$container || true
139+
done <<< \$(docker network inspect tck-net --format '{{range \$k, \$v := .Containers}}{{print \$k}}{{end}}' 2>/dev/null || true)
140+
docker network rm -f tck-net
141+
docker network create tck-net
142+
docker network connect tck-net ${containerName}
143+
"""
144+
sh """ \
145+
rm -Rf ./results
146+
docker rm -f tck || true
147+
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
148+
docker cp tck:/tck/persistence-tck/bin/target/failsafe-reports ./results
149+
docker cp tck:/tck/persistence-tck/bin/target/test-reports ./results
150+
"""
151+
}
152+
archiveArtifacts artifacts: 'results/**'
153+
script {
154+
failures = sh (
155+
script: """ \
156+
while read line; do
157+
if [[ "\$line" = *'-error" style="display:none;">' ]]; then
158+
prefix1='<tr class="a" id="'
159+
prefix2='<tr class="b" id="'
160+
suffix='-error" style="display:none;">'
161+
line=\${line#"\$prefix1"}
162+
line=\${line#"\$prefix2"}
163+
test=\${line%"\$suffix"}
164+
echo "\$test"
165+
fi
166+
done <results/test-reports/failsafe-report.html
167+
""",
168+
returnStdout: true
169+
).trim()
170+
if ( !failures.isEmpty() ) {
171+
echo "Some TCK tests failed:"
172+
echo failures
173+
currentBuild.result = 'FAILURE'
174+
}
175+
}
176+
}
177+
}
178+
}
169179
}
170180
}
171181
post {

0 commit comments

Comments
 (0)