diff --git a/src/main/java/com/google/devtools/build/lib/buildeventservice/BazelBuildEventServiceModule.java b/src/main/java/com/google/devtools/build/lib/buildeventservice/BazelBuildEventServiceModule.java index 3176da04f3dc78..c511bf72a57279 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventservice/BazelBuildEventServiceModule.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventservice/BazelBuildEventServiceModule.java @@ -98,4 +98,9 @@ protected String getInvocationIdPrefix() { ? besOptions.besResultsUrl : besOptions.besResultsUrl + "/"; } + + @Override + protected String getBuildRequestIdPrefix() { + return ""; + } } diff --git a/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java b/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java index 9dceed4ad03933..9b65b2e7caaeb0 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java @@ -72,6 +72,7 @@ public abstract class BuildEventServiceModule bepTransports; private String invocationId; + private String buildRequestId; private EventHandler cmdLineReporter; protected BESOptionsT besOptions; @@ -110,6 +111,7 @@ public Iterable> getCommonCommandOptions() { @Override public void beforeCommand(CommandEnvironment cmdEnv) { this.invocationId = cmdEnv.getCommandId().toString(); + this.buildRequestId = cmdEnv.getBuildRequestId(); this.cmdLineReporter = cmdEnv.getReporter(); // Reset to null in case afterCommand was not called. // TODO(lpino): Remove this statement once {@link BlazeModule#afterCommmand()} is guaranteed @@ -229,7 +231,18 @@ private void constructAndMaybeReportInvocationIdUrl() { } } - private void constructAndReportIds(String buildRequestId) { + private void constructAndMaybeReportBuildRequestIdUrl() { + if (!getBuildRequestIdPrefix().isEmpty()) { + cmdLineReporter.handle( + Event.info( + "See " + + getBuildRequestIdPrefix() + + buildRequestId + + " for more information about your request.")); + } + } + + private void constructAndReportIds() { cmdLineReporter.handle( Event.info( String.format( @@ -248,7 +261,7 @@ private BuildEventServiceTransport createBesTransport( return null; } - constructAndReportIds(cmdEnv.getBuildRequestId()); + constructAndReportIds(); final BuildEventServiceClient besClient; try { @@ -265,8 +278,8 @@ private BuildEventServiceTransport createBesTransport( BuildEventServiceProtoUtil besProtoUtil = new BuildEventServiceProtoUtil.Builder() - .buildRequestId(cmdEnv.getBuildRequestId()) - .invocationId(cmdEnv.getCommandId().toString()) + .buildRequestId(buildRequestId) + .invocationId(invocationId) .projectId(besOptions.projectId) .commandName(cmdEnv.getCommandName()) .keywords(getBesKeywords(besOptions, cmdEnv.getRuntime().getStartupOptionsProvider())) @@ -387,6 +400,7 @@ private ImmutableSet createBepTransports( createBesTransport(cmdEnv, uploaderSupplier, artifactGroupNamer); if (besTransport != null) { constructAndMaybeReportInvocationIdUrl(); + constructAndMaybeReportBuildRequestIdUrl(); bepTransportsBuilder.add(besTransport); } @@ -413,6 +427,9 @@ protected Set getBesKeywords( /** A prefix used when printing the invocation ID in the command line */ protected abstract String getInvocationIdPrefix(); + /** A prefix used when printing the build request ID in the command line */ + protected abstract String getBuildRequestIdPrefix(); + // TODO(b/115961387): This method shouldn't exist. It only does because some tests are relying on // the transport creation logic of this module directly. @VisibleForTesting