Skip to content

Commit 2d50f74

Browse files
mads-hartmannroboquat
authored andcommitted
Improve message when preview env build job fails
1 parent 1124ffb commit 2d50f74

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

.werft/workspace-run-integration-tests.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ git remote set-url origin https://oauth2:"${ROBOQUAT_TOKEN}"@github.com/gitpod-i
6060

6161
werft log phase "build preview environment" "build preview environment"
6262

63-
# Create branch off main and ask Werft to create a preview environment for it
63+
# Create a new branch and asks Werft to create a preview environment for it
6464
( \
6565
git checkout -B "${BRANCH}" && \
6666
echo "integration test" >> README.md && \
@@ -72,6 +72,12 @@ werft log phase "build preview environment" "build preview environment"
7272

7373
trap cleanup SIGINT SIGTERM EXIT
7474

75+
# Our current approach will start two Werft jobs. One triggered by Werft by the push to the branch and one
76+
# due to the `werft run` invocation above - the manual invocation is needed as we don't enable preview
77+
# environments by default.
78+
#
79+
# Below we find the job id of the the build that has 'with-preview' set. We don't care about the other job.
80+
#
7581
BUILD_ID=$(werft job list repo.ref==refs/heads/"${BRANCH}" -o yaml | yq4 '.result[] | select(.metadata.annotations[].key == "with-preview") | .name' | head -1)
7682
until [ "$BUILD_ID" != "" ]
7783
do
@@ -96,7 +102,17 @@ done
96102

97103
job_success="$(werft job get "${BUILD_ID}" -o json | jq --raw-output '.conditions.success')"
98104
if [[ ${job_success} == "null" ]]; then
99-
echo "build failed" | werft log slice "build preview environment"
105+
(
106+
echo "The build job for the preview environment failed." && \
107+
echo "" && \
108+
echo "See the logs for the job here for details on why: ${job_url}" && \
109+
echo "" && \
110+
echo "While this error is unrelated to our integration tests it does mean we can't continue as we don't have a target to run integration tests against without a working preview environment." && \
111+
echo "" && \
112+
echo "Marking this job as failed. Please retry the integration test job." && \
113+
echo "" \
114+
) | werft log slice "build preview environment"
115+
werft log slice "build preview environment" --fail "Build job for preview environment failed"
100116
exit 1
101117
fi
102118

0 commit comments

Comments
 (0)