diff --git a/.buildkite/pipeline-utils/test-failures/annotate.ts b/.buildkite/pipeline-utils/test-failures/annotate.ts index 43f3b733ebcd7..b90d22ec12eba 100644 --- a/.buildkite/pipeline-utils/test-failures/annotate.ts +++ b/.buildkite/pipeline-utils/test-failures/annotate.ts @@ -188,3 +188,15 @@ export const annotateTestFailures = async () => { ); } }; + +export const pingTeam = async () => { + if (process.env.ELASTIC_SLACK_NOTIFICATIONS_ENABLED === 'true') { + const reportSlackDir = 'target/report-slack-team'; + const team: string = recursiveReadDir(reportSlackDir).find((file) => file.endsWith('.slack')) || ''; + + buildkite.setMetadata( + 'slack:ping_team:body', + `@${team}, can you please take a look at the test failures?` + ); + } +}; diff --git a/.buildkite/scripts/common/env.sh b/.buildkite/scripts/common/env.sh index 1eb86de0bc030..e10f8773d70bf 100755 --- a/.buildkite/scripts/common/env.sh +++ b/.buildkite/scripts/common/env.sh @@ -7,6 +7,7 @@ export CI=true KIBANA_DIR=$(pwd) export KIBANA_DIR export XPACK_DIR="$KIBANA_DIR/x-pack" +export REPORT_SLACK_TEAM="target/report-slack-team" export CACHE_DIR="$HOME/.kibana" export ES_CACHE_DIR="$HOME/.es-snapshot-cache" diff --git a/.buildkite/scripts/lifecycle/ping_team_ftrs.ts b/.buildkite/scripts/lifecycle/ping_team_ftrs.ts new file mode 100644 index 0000000000000..337a80e8cb0f0 --- /dev/null +++ b/.buildkite/scripts/lifecycle/ping_team_ftrs.ts @@ -0,0 +1,23 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the "Elastic License + * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { TestFailures } from '#pipeline-utils'; + +(async () => { + try { + await TestFailures.pingTeam(); + } catch (ex) { + console.error('Ping team for the test failures error', ex.message); + if (ex.response) { + console.error('HTTP Error Response Status', ex.response.status); + console.error('HTTP Error Response Body', ex.response.data); + } + process.exit(1); + } +})(); diff --git a/.buildkite/scripts/lifecycle/post_command.sh b/.buildkite/scripts/lifecycle/post_command.sh index f90a4b451be1f..586f988543319 100755 --- a/.buildkite/scripts/lifecycle/post_command.sh +++ b/.buildkite/scripts/lifecycle/post_command.sh @@ -52,4 +52,8 @@ if [[ "$IS_TEST_EXECUTION_STEP" == "true" ]]; then buildkite-agent artifact upload 'target/test_failures/**/*' ts-node .buildkite/scripts/lifecycle/annotate_test_failures.ts fi + + if [[ -d "${REPORT_SLACK_TEAM}" ]]; then + ts-node .buildkite/scripts/lifecycle/ping_team_ftrs.ts + fi fi diff --git a/.buildkite/scripts/steps/functional/apm_cypress.sh b/.buildkite/scripts/steps/functional/apm_cypress.sh index 1b388eede871d..db79cad6119fd 100755 --- a/.buildkite/scripts/steps/functional/apm_cypress.sh +++ b/.buildkite/scripts/steps/functional/apm_cypress.sh @@ -29,8 +29,15 @@ fi echo "--- APM Cypress Tests" -cd "$XPACK_DIR" +pushd "$XPACK_DIR" -node solutions/observability/plugins/apm/scripts/test/e2e.js \ +if ! node solutions/observability/plugins/apm/scripts/test/e2e.js \ --kibana-install-dir "$KIBANA_BUILD_LOCATION" \ - $CYPRESS_ARGS + $CYPRESS_ARGS ; then + + # Report the error to the team using the subfolder matching the Slack Team + popd + mkdir "$REPORT_SLACK_TEAM" + touch "$REPORT_SLACK_TEAM"/obs-ux-infra_services-team.slack + exit 1 +fi diff --git a/.buildkite/scripts/steps/functional/profiling_cypress.sh b/.buildkite/scripts/steps/functional/profiling_cypress.sh index 318d45d0b125d..7e5d0c3dd83d8 100644 --- a/.buildkite/scripts/steps/functional/profiling_cypress.sh +++ b/.buildkite/scripts/steps/functional/profiling_cypress.sh @@ -12,7 +12,13 @@ export JOB=kibana-profiling-cypress echo "--- Profiling Cypress Tests" -cd "$XPACK_DIR" +pushd "$XPACK_DIR" -NODE_OPTIONS=--openssl-legacy-provider node solutions/observability/plugins/profiling/scripts/test/e2e.js \ - --kibana-install-dir "$KIBANA_BUILD_LOCATION" \ \ No newline at end of file +if ! NODE_OPTIONS=--openssl-legacy-provider node solutions/observability/plugins/profiling/scripts/test/e2e.js \ + --kibana-install-dir "$KIBANA_BUILD_LOCATION" ; then + # Report the error to the team using the subfolder matching the Slack Team + popd + mkdir "$REPORT_SLACK_TEAM" + touch "$REPORT_SLACK_TEAM"/obs-ux-infra_services-team.slack + exit 1 +fi