about summary refs log tree commit diff
path: root/nix/buildkite
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-01-20T09·49+0300
committertazjin <tazjin@tvl.su>2022-01-20T11·04+0000
commitd14c81007eefb01005156d4a0b7e34d41af5d5b4 (patch)
treee8e83246daa34972c925f9539204c6f5b145cfec /nix/buildkite
parenta874f5df78f944e2b7e0faaadcb41ccce7f90522 (diff)
fix(nix/buildkite): prevent swallowing errors from git-merge-base r/3640
The `local` usage we had before would silently swallow non-zero exit
statuses from the substituted git commands.

For some (as of yet unknown) reason, `git merge-base` seems to
sometimes silently fail and produce no output, which broke the rest of
the script logic.

This change will lead to an earlier error, but we don't know if it is
a fix for the actual cause of the git-merge-base problem because the
shape of that problem is unclear.

Change-Id: I4555c8638da450263fa2fd2c274dfdb69f65578e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5012
Tested-by: BuildkiteCI
Reviewed-by: kn <klemens@posteo.de>
Diffstat (limited to 'nix/buildkite')
-rwxr-xr-xnix/buildkite/fetch-parent-targets.sh12
1 files changed, 7 insertions, 5 deletions
diff --git a/nix/buildkite/fetch-parent-targets.sh b/nix/buildkite/fetch-parent-targets.sh
index d34a826279d0..9a8fecd1f460 100755
--- a/nix/buildkite/fetch-parent-targets.sh
+++ b/nix/buildkite/fetch-parent-targets.sh
@@ -15,12 +15,14 @@ set -ueo pipefail
 
 : ${DRVMAP_PATH:=pipeline/drvmap.json}
 
-function most_relevant_builds {
-    git fetch -v origin "${BUILDKITE_PIPELINE_DEFAULT_BRANCH}"
-    local FIRST=$(git merge-base --fork-point HEAD FETCH_HEAD)
-    local SECOND=$(git rev-parse "$FIRST~1")
-    local THIRD=$(git rev-parse "$FIRST~2")
+git fetch -v origin "${BUILDKITE_PIPELINE_DEFAULT_BRANCH}"
+
+FIRST=$(git merge-base --fork-point FETCH_HEAD "${BUILDKITE_COMMIT}")
+SECOND=$(git rev-parse "$FIRST~1")
+THIRD=$(git rev-parse "$FIRST~2")
 
+function most_relevant_builds {
+    set -u
     curl 'https://graphql.buildkite.com/v1' \
          --silent \
          -H "Authorization: Bearer $(cat /run/agenix/buildkite-graphql-token)" \