diff --git a/hooks/checkout b/hooks/checkout index cb43ab4..17af985 100755 --- a/hooks/checkout +++ b/hooks/checkout @@ -3,3 +3,5 @@ set -euo pipefail echo "--- Skipping checkout" +echo "Removing any old artifacts" +rm -rf ./* diff --git a/tests/checkout.bats b/tests/checkout.bats index 0b3a946..4da27ac 100644 --- a/tests/checkout.bats +++ b/tests/checkout.bats @@ -23,6 +23,17 @@ post_checkout_hook="$PWD/hooks/post-checkout" assert_output --partial "Skipping checkout" } +@test "Removes old artifacts { + export BUILDKITE_BUILD_CHECKOUT_PATH=$tmp_dir + cd "$BUILDKITE_BUILD_CHECKOUT_PATH" + touch some_old_artifact + + run "$checkout_hook" + + assert_success + refute [ -f some_old_artifact ] +} + @test "Updates checkout directory when 'cd' is given" { export BUILDKITE_BUILD_CHECKOUT_PATH=$tmp_dir export BUILDKITE_PLUGIN_SKIP_CHECKOUT_CD="/var"