File tree Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change 10
10
PLUGIN_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) /.."
11
11
MAX_SIZE=1024 # in KB
12
12
13
- echo " --- :junit: Download the junits"
14
-
15
13
artifacts_dir=" $( pwd) /$( mktemp -d " junit-annotate-plugin-artifacts-tmp.XXXXXXXXXX" ) "
16
14
annotation_dir=" $( pwd) /$( mktemp -d " junit-annotate-plugin-annotation-tmp.XXXXXXXXXX" ) "
17
15
annotation_path=" ${annotation_dir} /annotation.md"
@@ -31,9 +29,11 @@ function check_size {
31
29
32
30
trap cleanup EXIT
33
31
34
- buildkite-agent artifact download \
35
- " ${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS} " \
36
- " $artifacts_dir "
32
+ echo " --- :junit: Download the junits"
33
+ if ! buildkite-agent artifact download " ${BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS} " " $artifacts_dir " ; then
34
+ echo " --- :boom: Could not download artifacts"
35
+ exit 2
36
+ fi
37
37
38
38
echo " --- :junit: Processing the junits"
39
39
@@ -59,7 +59,7 @@ if [[ $exit_code -eq 64 ]]; then # special exit code to signal test failures
59
59
fail_build=1
60
60
fi
61
61
elif [[ $exit_code -ne 0 ]]; then
62
- echo " 🚨 Error when processing JUnit tests"
62
+ echo " --- :boom: Error when processing JUnit tests"
63
63
exit $exit_code
64
64
fi
65
65
Original file line number Diff line number Diff line change @@ -260,4 +260,27 @@ export annotation_input="tests/tmp/annotation.input"
260
260
unstub mktemp
261
261
unstub buildkite-agent
262
262
unstub docker
263
+ }
264
+
265
+
266
+
267
+ @test " error bubbles up when agent download fails" {
268
+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_ARTIFACTS=" junits/*.xml"
269
+ export BUILDKITE_PLUGIN_JUNIT_ANNOTATE_FAIL_BUILD_ON_ERROR=false
270
+
271
+ stub mktemp \
272
+ " -d \* : mkdir -p '$artifacts_tmp '; echo '$artifacts_tmp '" \
273
+ " -d \* : mkdir -p '$annotation_tmp '; echo '$annotation_tmp '"
274
+
275
+ stub buildkite-agent \
276
+ " artifact download \* \* : exit 1"
277
+
278
+ run " $PWD /hooks/command"
279
+
280
+ assert_failure 2
281
+
282
+ assert_output --partial " Could not download artifacts"
283
+
284
+ unstub mktemp
285
+ unstub buildkite-agent
263
286
}
You can’t perform that action at this time.
0 commit comments