diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index c79bc3a25..0a9ee356b 100644 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -1,5 +1,11 @@ set -euo pipefail +# Check that the target branch exists. +git fetch origin "${BUILDKITE_BRANCH}" || { + echo "Branch ${BUILDKITE_BRANCH} no longer exists; it was probably deleted by the time we got to it." >&2 + exit 1 +} + # Download any build-specific configuration that has been uploaded. # This allows top-level steps to override all subsequent steps. buildkite-agent artifact download 'tools/bazeldefs/*' . || true