Skip to content

Commit

Permalink
abort post-command on non-zero exit status
Browse files Browse the repository at this point in the history
resolves buildkite-plugins#80
if the command (eg, bundle install) fails partway through, the cache plugin could upload a poisoned cache
  • Loading branch information
amancevice committed Oct 15, 2024
1 parent d823b2e commit c8287ae
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hooks/post-command
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/bin/bash
set -euo pipefail

# skip caching if command exited non-zero
if [ $BUILDKITE_COMMAND_EXIT_STATUS -ne 0 ] ; then
echo "Aborting cache post-command hook because command exited with status $BUILDKITE_COMMAND_EXIT_STATUS"
exit 1
fi

DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"

# shellcheck source=lib/shared.bash
Expand Down

0 comments on commit c8287ae

Please # to comment.