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.
This commit is contained in:
Daniel Uber 2021-08-19 11:42:42 -05:00 committed by GitHub
parent bcd804f44d
commit ccbac93ea5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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