Skip to content

Commit

Permalink
[8.0.1] Allow native.bazel_version to be overridden for dev builds (#…
Browse files Browse the repository at this point in the history
…24772)

This is necessary to allow for accurate bisects of Bazel issues when
rules rely on `bazel_features` for feature detection. The variable can
be used to force the lowest version relevant to the bisect or, in the
future, `bazelisk --bisect` could extrapolate the release version from
tags.

Closes #24669.

PiperOrigin-RevId: 708009535
Change-Id: I89fad7db4e5443558815ff2351247786558a8ab6

Commit
b77fe10

Co-authored-by: Fabian Meumertzheim <[email protected]>
  • Loading branch information
bazel-io and fmeum authored Dec 20, 2024
1 parent d816b82 commit 7f283f8
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public class BlazeVersionInfo {
/** Key for the release timestamp is seconds. */
public static final String BUILD_TIMESTAMP = "Build timestamp as int";

// If the current version is a development version, this environment variable can be used to
// override the version string (e.g. to deal with version-based feature detection during a
// bisect).
public static final String BAZEL_DEV_VERSION_OVERRIDE_ENV_VAR = "BAZEL_DEV_VERSION_OVERRIDE";

private static final GoogleLogger logger = GoogleLogger.forEnclosingClass();

private static BlazeVersionInfo instance = null;
Expand Down Expand Up @@ -126,7 +131,14 @@ public String getReleaseName() {
*/
public String getVersion() {
String buildLabel = buildData.get(BUILD_LABEL);
return buildLabel != null ? buildLabel : "";
if (buildLabel != null) {
return buildLabel;
}
String override = System.getenv(BAZEL_DEV_VERSION_OVERRIDE_ENV_VAR);
if (override != null) {
return override;
}
return "";
}

/**
Expand Down

0 comments on commit 7f283f8

Please sign in to comment.