refactor(ci): enforce required env variables in build scripts#35990
Conversation
There was a problem hiding this comment.
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.
Add mandatory environment variable checks to key scripts for improved reliability and early failure detection.
| 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)}" |
There was a problem hiding this comment.
FYI I much prefer the current/old syntax
There was a problem hiding this comment.
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.
bf73ab3 to
6f54e3c
Compare
|
@hakonhall I rebased and improved handling of SOURCE_DIR in 6f54e3c |
What
Why