@@ -36,6 +36,13 @@ if [[ "${ARTIFACTS}" != "${REPO_ROOT}/_artifacts" ]]; then
3636 ARTIFACTS=$( mktemp -d)
3737fi
3838
39+ E2E_SH_LOG_FILE=" e2e-sh-log.txt"
40+
41+ # Redirect all output of this script additionally to a file in artifacts,
42+ # so we can create a junit file with its content in case of general CI failures.
43+ # This way the bash script's log can be analyzed using k8s-triage.
44+ exec & > >( stdbuf -oL tee " ${ARTIFACTS} /${E2E_SH_LOG_FILE} " )
45+
3946# shellcheck source=./hack/ensure-go.sh
4047source " ${REPO_ROOT} /hack/ensure-go.sh"
4148
@@ -52,7 +59,9 @@ on_exit() {
5259 [[ -z ${HEART_BEAT_PID:- } ]] || kill -9 " ${HEART_BEAT_PID} "
5360
5461 # If Boskos is being used then release the vsphere project.
55- [ -z " ${BOSKOS_HOST:- } " ] || docker run -e VSPHERE_USERNAME -e VSPHERE_PASSWORD gcr.io/k8s-staging-capi-vsphere/extra/boskosctl:latest release --boskos-host=" ${BOSKOS_HOST} " --resource-owner=" ${BOSKOS_RESOURCE_OWNER} " --resource-name=" ${BOSKOS_RESOURCE_NAME} " --vsphere-server=" ${VSPHERE_SERVER} " --vsphere-tls-thumbprint=" ${VSPHERE_TLS_THUMBPRINT} " --vsphere-folder=" ${BOSKOS_RESOURCE_FOLDER} " --vsphere-resource-pool=" ${BOSKOS_RESOURCE_POOL} "
62+ if [[ " ${BOSKOS_HOST:- } " != " " && " ${BOSKOS_RESOURCE_NAME:- } " != " " ]]; then
63+ docker run -e VSPHERE_USERNAME -e VSPHERE_PASSWORD gcr.io/k8s-staging-capi-vsphere/extra/boskosctl:latest release --boskos-host=" ${BOSKOS_HOST} " --resource-owner=" ${BOSKOS_RESOURCE_OWNER} " --resource-name=" ${BOSKOS_RESOURCE_NAME} " --vsphere-server=" ${VSPHERE_SERVER} " --vsphere-tls-thumbprint=" ${VSPHERE_TLS_THUMBPRINT} " --vsphere-folder=" ${BOSKOS_RESOURCE_FOLDER} " --vsphere-resource-pool=" ${BOSKOS_RESOURCE_POOL} "
64+ fi
5665 fi
5766
5867 # Cleanup VSPHERE_PASSWORD from temporary artifacts directory.
@@ -97,6 +106,18 @@ on_exit() {
97106 # Move all artifacts to the original artifacts location.
98107 mv " ${ARTIFACTS} " /* " ${ORIGINAL_ARTIFACTS} /"
99108 fi
109+
110+ # Create a junit file for running this script.
111+
112+ # Delete output file from this script because it contains a duplicate output
113+ if ls -1 " ${ORIGINAL_ARTIFACTS} " 2> /dev/null | grep -q " ^junit\..*\.xml$" ; then
114+ # There are junit files in artifacts
115+ junit::createJunitReportE2Esh 0 " ${ORIGINAL_ARTIFACTS} /junit.e2e-sh.xml"
116+ else
117+ junit::createJunitReportE2Esh 1 " ${ORIGINAL_ARTIFACTS} /junit.e2e-sh.xml" " ${ORIGINAL_ARTIFACTS} /${E2E_SH_LOG_FILE} "
118+ fi
119+ # Cleanup the additionally written log file, the same content will be in build-log.txt.
120+ rm " ${ORIGINAL_ARTIFACTS} /${E2E_SH_LOG_FILE} "
100121}
101122
102123trap on_exit EXIT
0 commit comments