#!/usr/bin/env groovy
node {
def API_JAR_NAME = "jakarta.security.enterprise-api.jar"
def DOWNLOAD_API_JAR_NAME = "jakarta.security.enterprise-api-1.0.2.jar"
// TCK properties
env.deliverabledir="security"
env.TCK_HOME="${env.WORKSPACE}"
env.TS_HOME="${env.WORKSPACE}/${env.deliverabledir}-tck"
env.javaee_home="${env.WORKSPACE}/glassfish5"
env.ANT_VERSION='1.9.13'
env.TOOLS_PREFIX='/opt/tools'
env.JAVA_PREFIX="${TOOLS_PREFIX}/java/oracle"
env.MVN_HOME="${TOOLS_PREFIX}/apache-maven/latest"
env.JAVA_HOME="${JAVA_PREFIX}/jdk-8/latest"
env.PATH="${MVN_HOME}/bin:${JAVA_HOME}/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
env.ANT_HOME="${TS_HOME}/tools/ant"
env.PATH="${ANT_HOME}/bin:${PATH}"
env.ANT_OPTS="-Djavax.xml.accessExternalSchema=all"
stage("Init") {
sh '''#!/bin/bash -x
mkdir download
'''
}
stage("Grab GF") {
env.GF_URL = "${GF_URL}"
sh '''#!/bin/bash -ex
cd ${WORKSPACE}/download
wget -q ${GF_URL} -O glassfish.zip
cd ${WORKSPACE}
unzip -q ${WORKSPACE}/download/glassfish.zip
'''
}
stage("Grab API") {
env.API_URL = "${API_URL}"
env.API_JAR_NAME = "${API_JAR_NAME}"
sh '''#!/bin/bash -ex
cd ${WORKSPACE}/download
wget -q ${API_URL} -O ${API_JAR_NAME}
'''
}
stage("Grab TCK") {
env.TCK_BUNDLE_URL = "${TCK_BUNDLE_URL}"
sh '''#!/bin/bash -ex
cd ${WORKSPACE}/download
wget -q ${TCK_BUNDLE_URL} -O ${deliverabledir}tck.zip
cd ${WORKSPACE}
unzip ${WORKSPACE}/download/${deliverabledir}tck.zip
'''
}
stage ("Grab ANT") {
sh '''#!/bin/bash -ex
cd ${WORKSPACE}/download
tar xfz ant.tar.gz
mkdir -p ${ANT_HOME} && cp -a ${WORKSPACE}/download/apache-ant-${ANT_VERSION}/. ${ANT_HOME}
'''
}
stage ("Replace API in GF") {
env.API_JAR_NAME = "${API_JAR_NAME}"
env.DOWNLOAD_API_JAR_NAME = "${DOWNLOAD_API_JAR_NAME}"
sh '''#!/bin/bash -ex
rm $javaee_home/glassfish/modules/${API_JAR_NAME}
cp -v ${WORKSPACE}/download/${API_JAR_NAME} $javaee_home/glassfish/modules
'''
}
stage ("Configure ts.jte") {
sh '''#!/bin/bash -ex
cd ${TS_HOME}/bin/
sed -i "s#web.home=.*#web.home=$TCK_HOME/glassfish5/glassfish#g" ts.jte
sed -i "s#^report.dir=.*#report.dir=$TCK_HOME/securityapitckreport/securityapitck#g" ts.jte
sed -i "s#^work.dir=.*#work.dir=$TCK_HOME/securityapitckwork/securityapitck#g" ts.jte
sed -i 's#securityapi.classes=.*#securityapi.classes=${web.home}/modules/jakarta.servlet-api.jar${pathsep}${web.home}/modules/jakarta.security.enterprise-api.jar${pathsep}${web.home}/modules/jakarta.security.auth.message-api.jar${pathsep}${web.home}/modules/endorsed/jakarta.annotation-api.jar${pathsep}${web.home}/modules/jakarta.inject.jar${pathsep}${web.home}/modules/cdi-api.jar${pathsep}${web.home}/modules/jakarta.faces.jar${pathsep}${web.home}/modules/jakarta.interceptor-api.jar${pathsep}${web.home}/modules/jakarta.ejb-api.jar${pathsep}/${ts.home}/lib/unboundid-ldapsdk.jar#g' ts.jte
'''
}
stage("Restart GF") {
sh '''#!/bin/bash -ex
cd $javaee_home/bin
./asadmin stop-domain
if [ $retval != 0 ]; then
echo "Pending process to be killed:"
ps -eaf | grep "com.sun.enterprise.admin.cli.AdminMain" | grep -v "grep" | grep -v "nohup"
for i in `ps -eaf | grep "com.sun.enterprise.admin.cli.AdminMain" | grep -v "grep" | grep -v "nohup" | tr -s " " | cut -d" " -f2`
do
echo "[killJava.sh] kill -9 $i"
kill $i
done
fi
./asadmin start-domain
'''
}
stage("Configure TCK") {
sh '''#!/bin/bash -ex
cd ${TS_HOME}/bin
ant init.ldap
'''
}
stage ("Run TCK tests") {
sh '''#!/bin/bash -x
cd $TS_HOME/bin
ant deploy.all
ant run.all | tee -a ${TS_HOME}/bin/run.log
'''
}
stage ("Create summary.txt, API, and run.log artifacts") {
sh '''#!/bin/bash -ex
cd ${TS_HOME}/bin
cat run.log | sed -e '1,/Completed running/d' > summary.txt
PASSED_COUNT=`head -1 summary.txt | tail -1 | sed 's/.*=\\s\\(.*\\)/\\1/'`
FAILED_COUNT=`head -2 summary.txt | tail -1 | sed 's/.*=\\s\\(.*\\)/\\1/'`
ERROR_COUNT=`head -3 summary.txt | tail -1 | sed 's/.*=\\s\\(.*\\)/\\1/'`
SHA256_GF=`openssl dgst -sha256 ${WORKSPACE}/download/glassfish.zip`
SHA256_API=`openssl dgst -sha256 ${WORKSPACE}/download/${API_JAR_NAME}`
SHA256_TCK=`openssl dgst -sha256 ${WORKSPACE}/download/${deliverabledir}tck.zip`
echo ERROR_COUNT=${ERROR_COUNT}
echo FAILED_COUNT=${FAILED_COUNT}
echo PASSED_COUNT=${PASSED_COUNT}
echo SHA256_GF=${SHA256_GF} | tee -a summary.txt
echo SHA256_API=${SHA256_API} | tee -a summary.txt
echo SHA256_TCK=${SHA256_TCK} | tee -a summary.txt
'''
archiveArtifacts artifacts: "${env.deliverabledir}-tck/bin/summary.txt", fingerprint: true
archiveArtifacts artifacts: "${env.deliverabledir}-tck/bin/run.log", fingerprint: true
archiveArtifacts artifacts: "glassfish5/glassfish/modules/${API_JAR_NAME}", fingerprint: true
}
}