#!/usr/bin/env groovy
node {
env.deliverabledir="jsonb"
// value of ${ts.home} is to be evaluated by ANT during the build/run
// in ts.jte it is supposed to be ${ts.home}, it is test suite home folder,
// where the test suite is to be cloned from the GitHub repository
// Location of a glassfish when the TCK is being run
env.SERVER_HOME="\${ts.home}/../glassfish5/glassfish"
// The folder of TCK job results
env.HARNESS_REPORT_DIR="\${ts.home}/../JTreport"
// Java Test Harness work dir
env.HARNESS_WORK_DIR="\${ts.home}/../JTwork"
env.JARS_ON_CP="\
\${web.home}/modules/cdi-api.jar:\
\${web.home}/modules/jakarta.ejb-api.jar:\
\${web.home}/modules/jakarta.inject.jar:\
\${web.home}/modules/jakarta.json.jar:\
\${web.home}/modules/jakarta.json-api.jar:\
\${web.home}/modules/jakarta.json.bind-api.jar:\
\${web.home}/modules/jakarta.persistence.jar:\
\${web.home}/modules/jakarta.servlet-api.jar:\
\${web.home}/modules/jakarta.transaction-api.jar:\
\${web.home}/modules/osgi-resource-locator.jar:\
\${web.home}/modules/weld-osgi-bundle.jar:\
\${web.home}/modules/yasson.jar"
stage('Grab the original ts.jte') {
// get the ts.jte file
sh "wget https://raw.githubusercontent.com/eclipse-ee4j/jakartaee-tck/master/install/${deliverabledir}/bin/ts.jte"
}
stage('Configure the ts.jte') {
sh '''#!/bin/bash -ex
sed -i '$ a impl\\.vi=glassfish' ts.jte
sed -i "$ a web\\.home=\$(echo \${SERVER_HOME} | sed -e 's/\\\\/\\\\\\\\/g; s/\\//\\\\\\//g;')" ts.jte
sed -i "s/^impl\\.vi\\.deploy\\.dir=/$(echo impl\\.vi\\.deploy\\.dir=\\${web.home}/domains/domain1/autodeploy | sed -e 's/\\\\/\\\\\\\\/g; s/\\//\\\\\\//g;')/g" ts.jte
sed -i 's/^harness\\.log\\.traceflag=false/harness\\.log\\.traceflag=true/g' ts.jte
sed -i 's/^webServerHost=/webServerHost=localhost/g' ts.jte
sed -i 's/^webServerPort=/webServerPort=8080/g' ts.jte
sed -i "s/^work\\.dir=\\/tmp\\/JTwork/$(echo work\\.dir=${HARNESS_WORK_DIR} | sed -e 's/\\\\/\\\\\\\\/g; s/\\//\\\\\\//g;')/g" ts.jte
sed -i "s/^report\\.dir=\\/tmp\\/JTreport/$(echo report\\.dir=${HARNESS_REPORT_DIR} | sed -e 's/\\\\/\\\\\\\\/g; s/\\//\\\\\\//g;')/g" ts.jte
sed -i "s/^jsonb\\.classes=/$(echo jsonb\\.classes=${JARS_ON_CP} | sed -e 's/\\\\/\\\\\\\\/g; s/\\//\\\\\\//g;')/g" ts.jte
'''
}
stage('Archive the ts.jte') {
archiveArtifacts 'ts.jte'
}
}