Skip to content

Commit da3828e

Browse files
feat: [DevOps] Slack notification (#477)
* feat: [DevOps] Slack notification * add error * fails on test * Revert "fails on test" This reverts commit 3507b27. * exit 1 * also escape " * ugh * echo * 2 blocks 🏢🏢 * code block * Revert "code block" This reverts commit fb44f7f. * revert failure
1 parent a9732fc commit da3828e

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

.github/workflows/e2e-test.yaml

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,25 @@ jobs:
3939
mvn $MVN_ARGS
4040
4141
- name: "Run tests"
42+
id: run_tests
4243
run: |
4344
MVN_ARGS="${{ env.MVN_MULTI_THREADED_ARGS }} surefire:test -pl :spring-app -DskipTests=false"
44-
mvn $MVN_ARGS "-Daicore.landscape=${{ matrix.environment }}"
45+
mvn $MVN_ARGS "-Daicore.landscape=${{ matrix.environment }}" | tee mvn_output.log # tee writes to both the console and a file
46+
47+
awk '/Results:/, /----/' mvn_output.log > test_error.log || true # true ensures the step doesn't fail if no match is found.
48+
ERROR_MSG=$(cat test_error.log | tail +4 | head -n -4 | awk '{gsub(/"/, "\\\""); printf "%s\\n", $0}') # Slack formatting
49+
echo "$ERROR_MSG"
50+
echo "error_message=$ERROR_MSG" >> $GITHUB_OUTPUT
51+
52+
if grep -q "BUILD FAILURE" mvn_output.log; then
53+
echo "Maven build failed."
54+
exit 1
55+
elif grep -q "BUILD SUCCESS" mvn_output.log; then
56+
echo "Maven build succeeded."
57+
else
58+
echo "Maven build status unknown."
59+
exit 1
60+
fi
4561
env:
4662
# See "End-to-end test application instructions" on the README.md to update the secret
4763
AICORE_SERVICE_KEY: ${{ secrets[matrix.secret-name] }}
@@ -74,7 +90,12 @@ jobs:
7490
webhook: ${{ secrets.SLACK_WEBHOOK }}
7591
webhook-type: incoming-webhook
7692
payload: |
77-
{
78-
"text": "⚠️ End-to-end tests failed! 😬 Please inspect & fix by clicking <https://github.com/SAP/ai-sdk-java/actions/runs/${{ github.run_id }}|here>"
79-
}
80-
93+
blocks:
94+
- type: "section"
95+
text:
96+
type: "mrkdwn"
97+
text: "⚠️ End-to-end tests failed! 😬 Please inspect & fix by clicking <https://github.com/SAP/ai-sdk-java/actions/runs/${{ github.run_id }}|here>"
98+
- type: "section"
99+
text:
100+
type: "plain_text"
101+
text: "${{ steps.run_tests.outputs.error_message }}"

0 commit comments

Comments
 (0)