@@ -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
@@ -56,7 +63,9 @@ on_exit() {
5663 [[ -z ${HEART_BEAT_PID:- } ]] || kill -9 " ${HEART_BEAT_PID} "
5764
5865 # If Boskos is being used then release the vsphere project.
59- [ -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} "
66+ if [[ " ${BOSKOS_HOST:- } " != " " && " ${BOSKOS_RESOURCE_NAME:- } " != " " ]]; then
67+ 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} "
68+ fi
6069 fi
6170
6271 # Cleanup VSPHERE_PASSWORD from temporary artifacts directory.
@@ -101,6 +110,17 @@ on_exit() {
101110 # Move all artifacts to the original artifacts location.
102111 mv " ${ARTIFACTS} " /* " ${ORIGINAL_ARTIFACTS} /"
103112 fi
113+
114+ # Create a junit file for running this script.
115+ if [[ $( find " ${ORIGINAL_ARTIFACTS} " -maxdepth 1 -name ' junit\.*\.xml' | wc -l) -gt 0 ]]; then
116+ # There are junit files in artifacts so the script succeeded.
117+ junit::createJunitReportE2Esh 0 " ${ORIGINAL_ARTIFACTS} /junit.e2e-sh.xml"
118+ else
119+ # No junit files in artifacts so the script failed.
120+ junit::createJunitReportE2Esh 1 " ${ORIGINAL_ARTIFACTS} /junit.e2e-sh.xml" " ${ORIGINAL_ARTIFACTS} /${E2E_SH_LOG_FILE} "
121+ fi
122+ # Always cleanup the additionally written log file used for the junit report, the same content will be in build-log.txt.
123+ rm " ${ORIGINAL_ARTIFACTS} /${E2E_SH_LOG_FILE} "
104124}
105125
106126trap on_exit EXIT
0 commit comments