File tree Expand file tree Collapse file tree 4 files changed +21
-0
lines changed Expand file tree Collapse file tree 4 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 11#! /bin/bash
22set -euo pipefail
33
4+ # skip caching if command exited non-zero
5+ if [ " ${BUILDKITE_COMMAND_EXIT_STATUS} " -ne 0 ] ; then
6+ echo " Aborting cache post-command hook because command exited with status $BUILDKITE_COMMAND_EXIT_STATUS "
7+ exit 0
8+ fi
9+
410DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
511
612# shellcheck source=lib/shared.bash
Original file line number Diff line number Diff line change 77setup () {
88 load " ${BATS_PLUGIN_PATH} /load.bash"
99
10+ export BUILDKITE_COMMAND_EXIT_STATUS=0
11+
1012 mkdir -p tests/data/my_files
1113 echo " all the llamas" > " tests/data/my_files/llamas.txt"
1214 echo " no alpacas" > " tests/data/my_files/alpacas.txt"
Original file line number Diff line number Diff line change 77setup () {
88 load " ${BATS_PLUGIN_PATH} /load.bash"
99
10+ export BUILDKITE_COMMAND_EXIT_STATUS=0
11+
1012 mkdir -p tests/data/my_files
1113 echo " all the llamas" > " tests/data/my_files/llamas.txt"
1214 echo " no alpacas" > " tests/data/my_files/alpacas.txt"
Original file line number Diff line number Diff line change 66setup () {
77 load " ${BATS_PLUGIN_PATH} /load.bash"
88
9+ export BUILDKITE_COMMAND_EXIT_STATUS=0
10+
911 mkdir -p tests/data/my_files
1012 echo " all the llamas" > " tests/data/my_files/llamas.txt"
1113 echo " no alpacas" > " tests/data/my_files/alpacas.txt"
@@ -34,6 +36,15 @@ teardown() {
3436 assert_output --partial ' Cache not setup for saving'
3537}
3638
39+ @test ' If command failed, do nothing' {
40+ export BUILDKITE_COMMAND_EXIT_STATUS=127
41+
42+ run " $PWD /hooks/post-command"
43+
44+ assert_success
45+ assert_output --partial ' Aborting cache post-command hook because command exited with status 127'
46+ }
47+
3748@test " Missing path fails" {
3849 unset BUILDKITE_PLUGIN_CACHE_PATH
3950
You can’t perform that action at this time.
0 commit comments