diff --git a/.ibm/pipelines/cleanup.sh b/.ibm/pipelines/cleanup.sh index f69c570902..716ccb8dd7 100755 --- a/.ibm/pipelines/cleanup.sh +++ b/.ibm/pipelines/cleanup.sh @@ -13,6 +13,13 @@ cleanup() { log::error "Exited with an error, setting OVERALL_RESULT to 1" save_overall_result 1 fi + # Write TESTS_PASSED marker to SHARED_DIR for gather-extra/must-gather optimization. + # When present, the openshift/release post-phase steps can skip heavy artifact collection. + if [[ "${OVERALL_RESULT:-1}" == "0" && -n "${SHARED_DIR:-}" ]]; then + touch "${SHARED_DIR}/TESTS_PASSED" + log::info "TESTS_PASSED marker written to ${SHARED_DIR}" + fi + if [[ "${OPENSHIFT_CI}" == "true" ]]; then log::info "Cleaning up before exiting" case "$JOB_NAME" in diff --git a/.ibm/pipelines/lib/testing.sh b/.ibm/pipelines/lib/testing.sh index 4ba17a1942..aff7492ca1 100644 --- a/.ibm/pipelines/lib/testing.sh +++ b/.ibm/pipelines/lib/testing.sh @@ -187,7 +187,6 @@ testing::check_backstage_running() { oc get events -n "${namespace}" --sort-by='.lastTimestamp' | tail -20 mkdir -p "${ARTIFACT_DIR}/${namespace}" cp -a "/tmp/${LOGFILE}" "${ARTIFACT_DIR}/${namespace}/" || true - save_all_pod_logs "${namespace}" return 1 fi @@ -199,7 +198,6 @@ testing::check_backstage_running() { oc get events -n "${namespace}" --sort-by='.lastTimestamp' | tail -10 mkdir -p "${ARTIFACT_DIR}/${namespace}" cp -a "/tmp/${LOGFILE}" "${ARTIFACT_DIR}/${namespace}/" || true - save_all_pod_logs "${namespace}" return 1 } @@ -248,7 +246,13 @@ testing::check_and_test() { save_status_test_failed $CURRENT_DEPLOYMENT true save_overall_result 1 fi - save_all_pod_logs "$namespace" + + # Collect pod logs only on failure to speed up successful PR runs. + if [[ "${STATUS_TEST_FAILED[$CURRENT_DEPLOYMENT]:-}" == "true" || "${STATUS_FAILED_TO_DEPLOY[$CURRENT_DEPLOYMENT]:-}" == "true" ]]; then + save_all_pod_logs "$namespace" + else + log::info "Tests passed — skipping pod log collection for namespace: ${namespace}" + fi return 0 }