Skip to content

Commit 612ffc3

Browse files
author
Dmytro Rezchykov
committed
Add gradle link on CI comment when build failed.
1 parent c5d55de commit 612ffc3

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

.github/workflows/test-command.yml

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ jobs:
205205
comment-id: ${{ github.event.inputs.comment-id }}
206206
body: |
207207
> :x: ${{github.event.inputs.connector}} https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
208+
> :bug: ${{env.GRADLE_SCAN_LINK}}
208209
# In case of self-hosted EC2 errors, remove this block.
209210
stop-test-runner:
210211
name: Stop Build EC2 Runner

tools/bin/ci_integration_test.sh

+16-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set -e
88

99
connector="$1"
1010
all_integration_tests=$(./gradlew integrationTest --dry-run | grep 'integrationTest SKIPPED' | cut -d: -f 4)
11-
11+
run() {
1212
if [[ "$connector" == "all" ]] ; then
1313
echo "Running: ./gradlew --no-daemon --scan integrationTest"
1414
./gradlew --no-daemon --scan integrationTest
@@ -36,6 +36,20 @@ else
3636
./gradlew --no-daemon --scan "$integrationTestCommand"
3737
else
3838
echo "Connector '$connector' not found..."
39-
exit 1
39+
return 1
4040
fi
4141
fi
42+
}
43+
44+
# Copy command output to extract gradle scan link.
45+
run | tee build.out
46+
# return status of "run" command, not "tee"
47+
# https://tldp.org/LDP/abs/html/internalvariables.html#PIPESTATUSREF
48+
run_status=${PIPESTATUS[0]}
49+
test $run_status == "0" || {
50+
# Save gradle scan link to github GRADLE_SCAN_LINK variable for next job.
51+
# https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
52+
LINK=$(cat build.out | grep -A1 "Publishing build scan..." | tail -n1 | tr -d "\n")
53+
echo "GRADLE_SCAN_LINK=$LINK" >> $GITHUB_ENV
54+
}
55+
exit $run_status

0 commit comments

Comments
 (0)