Skip to content

refactor(ci): enforce required env variables in build scripts#35990

Merged
esolitos merged 2 commits into
masterfrom
marlon/refactor/ci-env-variable-checks
Apr 14, 2026
Merged

refactor(ci): enforce required env variables in build scripts#35990
esolitos merged 2 commits into
masterfrom
marlon/refactor/ci-env-variable-checks

Conversation

@esolitos

@esolitos esolitos commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

What

  • Uniform validation of mandatory env variables through shell expansion in builds scripts.

Why

  • Improved reliability and uniform early failure detection.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors environment variable validation in Buildkite CI build scripts to use a uniform shell parameter expansion pattern (: "${VAR:?message}"). This replaces explicit if-else checks with a more concise and consistent approach that provides descriptive error messages when required variables are missing.

Changes:

  • Replaced manual if-else validation checks with shell parameter expansion in upload-test-results.sh
  • Added environment variable validation to 9 build scripts using the uniform pattern
  • Improved error messages with descriptive context for each variable

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
.buildkite/upload-test-results.sh Replaced if-else checks for JAVA_TEST_TOKEN and CPP_TEST_TOKEN with parameter expansion validation
.buildkite/quick-start-guide.sh Added validation for SOURCE_DIR
.buildkite/java.sh Added validation for SOURCE_DIR, VESPA_MAVEN_TARGET, and NUM_MVN_THREADS
.buildkite/install.sh Added validation for NUM_CPU_LIMIT and WORKDIR
.buildkite/go.sh Added validation for SOURCE_DIR and WORKDIR
.buildkite/cpp.sh Added validation for SOURCE_DIR and NUM_CPP_THREADS
.buildkite/cpp-test.sh Added validation for NUM_CPU_LIMIT and LOG_DIR
.buildkite/build-container.sh Added validation for VESPA_BUILDOS_LABEL
.buildkite/bootstrap.sh Added validation for SOURCE_DIR and VESPA_CPP_TEST_JARS
.buildkite/bootstrap-cmake.sh Added validation for SOURCE_DIR

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .buildkite/upload-test-results.sh
Comment thread .buildkite/upload-test-results.sh
Comment thread .buildkite/build-container.sh
Comment thread .buildkite/bootstrap-cmake.sh Outdated
Add mandatory environment variable checks to key scripts for improved
reliability and early failure detection.
hakonhall
hakonhall previously approved these changes Apr 14, 2026
echo "Missing CPP_TEST_TOKEN. Exiting."
exit 1
fi
: "${JAVA_TEST_TOKEN:?Environment variable JAVA_TEST_TOKEN must be set (token for uploading Java test results)}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI I much prefer the current/old syntax

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in... the if?

If so: I also like it more as it is very easy to spot.
However I find the :"${VAR?:?error msg}` much more practical, especially when you have many, and each uses a single like, very compact and elegant.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@esolitos esolitos force-pushed the marlon/refactor/ci-env-variable-checks branch from bf73ab3 to 6f54e3c Compare April 14, 2026 10:08
@esolitos

Copy link
Copy Markdown
Contributor Author

@hakonhall I rebased and improved handling of SOURCE_DIR in 6f54e3c

@esolitos esolitos merged commit 3c6a7c5 into master Apr 14, 2026
4 checks passed
@esolitos esolitos deleted the marlon/refactor/ci-env-variable-checks branch April 14, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants