Skip to content

Commit aad253f

Browse files
authored
V16 QA add slack webhook for e2e tests (#19866)
* Added stage to notify slackbot * Update nightly-E2E-test-pipelines.yml for Azure Pipelines * Fixed indentation * Update nightly-E2E-test-pipelines.yml for Azure Pipelines * Updated stage name * Added issues to condition * Fixed SucceededWithIssues condition * Added dependencies to condition * Text formatting cleanup * Clarified webhook variable name * Updated url * Added another url * Added URL encoding * Added missing $ * Added comments
1 parent e3da179 commit aad253f

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

build/nightly-E2E-test-pipelines.yml

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ schedules:
1212
- main
1313

1414
parameters:
15-
# Skipped due to DB locks
15+
# Skipped due to DB locks
1616
- name: sqliteAcceptanceTests
1717
displayName: Run SQLite Acceptance Tests
1818
type: boolean
@@ -482,4 +482,52 @@ stages:
482482
testResultsFormat: 'JUnit'
483483
testResultsFiles: '*.xml'
484484
searchFolder: "tests/Umbraco.Tests.AcceptanceTest/results"
485-
testRunTitle: "$(Agent.JobName)"
485+
testRunTitle: "$(Agent.JobName)"
486+
487+
- stage: NotifySlackBot
488+
displayName: Notify Slack on Failure
489+
dependsOn: E2E
490+
# This stage will only run if the E2E tests fail or succeed with issues
491+
condition: or(
492+
eq(dependencies.E2E.result, 'failed'),
493+
eq(dependencies.E2E.result, 'succeededWithIssues'))
494+
jobs:
495+
- job: PostToSlack
496+
displayName: Send Slack Notification
497+
pool:
498+
vmImage: 'ubuntu-latest'
499+
steps:
500+
# We send a payload to the Slack webhook URL, which will post a message to a specific channel
501+
- bash: |
502+
PROJECT_NAME_ENCODED=$(echo -n "$SYSTEM_TEAMPROJECT" | jq -s -R -r @uri)
503+
PIPELINE_URL="${SYSTEM_TEAMFOUNDATIONCOLLECTIONURI}${PROJECT_NAME_ENCODED}/_build/results?buildId=${BUILD_BUILDID}&view=ms.vss-test-web.build-test-results-tab"
504+
505+
PAYLOAD="{
506+
\"attachments\": [
507+
{
508+
\"color\": \"#ff0000\",
509+
\"pretext\": \"Nightly E2E pipeline *${BUILD_DEFINITIONNAME}* (#${BUILD_BUILDNUMBER}) failed!\",
510+
\"title\": \"View Failed E2E Test Results\",
511+
\"title_link\": \"$PIPELINE_URL\",
512+
\"fields\": [
513+
{
514+
\"title\": \"Pipeline\",
515+
\"value\": \"${BUILD_DEFINITIONNAME}\",
516+
\"short\": true
517+
},
518+
{
519+
\"title\": \"Build ID\",
520+
\"value\": \"${BUILD_BUILDID}\",
521+
\"short\": true
522+
}
523+
]
524+
}
525+
]
526+
}"
527+
528+
echo "Sending Slack message to: $PIPELINE_URL"
529+
curl -X POST -H 'Content-type: application/json' \
530+
--data "$PAYLOAD" \
531+
"$SLACK_WEBHOOK_URL"
532+
env:
533+
SLACK_WEBHOOK_URL: $(E2ESLACKWEBHOOKURL)

0 commit comments

Comments
 (0)