From ccbac93ea5bb02a81a5d5a8f460749597978e14e Mon Sep 17 00:00:00 2001 From: Daniel Uber Date: Thu, 19 Aug 2021 11:42:42 -0500 Subject: [PATCH] Only print BUILDKITE environment variables when they were present (#14487) * Only print BUILDKITE environment variables when they were present This was causing errors running the build_containers.sh script locally, since only buildkite was passing these (and errors stop the script, so nothing was built). * Simplify conditional guards to check only for BUILDKITE variable https://buildkite.com/docs/pipelines/environment-variables#bk-env-vars-buildkite describes the simplest "this is buildkite" check, BUILDKITE is always true when running in buildkite. --- scripts/build_containers.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/build_containers.sh b/scripts/build_containers.sh index d6496b74a..433ccffce 100755 --- a/scripts/build_containers.sh +++ b/scripts/build_containers.sh @@ -161,10 +161,13 @@ function prune_containers { trap prune_containers ERR INT EXIT -echo "Branch: $BUILDKITE_BRANCH" -echo "PR : $BUILDKITE_PULL_REQUEST" -echo "Commit: $BUILDKITE_COMMIT" -echo "Tag : $BUILDKITE_TAG" +if [ -v BUILDKITE ] +then + echo "Branch: $BUILDKITE_BRANCH" + echo "PR : $BUILDKITE_PULL_REQUEST" + echo "Commit: $BUILDKITE_COMMIT" + echo "Tag : $BUILDKITE_TAG" +fi if [ ! -v BUILDKITE_BRANCH ]; then