diff options
author | 2018-06-08 07:24:03 -0700 | |
---|---|---|
committer | 2018-06-08 07:26:14 -0700 | |
commit | 28e4e91e307342f4fe05df93e8a8121bdd64caca (patch) | |
tree | 2696558419bed386619e37e4d0a05874c942dd49 /src/main/java/com/google/devtools/build/lib/buildeventservice | |
parent | 30ef629d77b86a0effc47ad2a5c01e757951ecc6 (diff) |
Print an additional link at the end of the build pointing where the Build Event Protocol is being streamed.
PiperOrigin-RevId: 199790757
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/buildeventservice')
2 files changed, 33 insertions, 14 deletions
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 513879243a..80c5599620 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 @@ -224,20 +224,23 @@ public abstract class BuildEventServiceModule<T extends BuildEventServiceOptions logger.fine(format("Will create BuildEventServiceTransport streaming to '%s'", besOptions.besBackend)); - final String message; + final String besResultsUrl; if (!Strings.isNullOrEmpty(besOptions.besResultsUrl)) { - String url = + besResultsUrl = besOptions.besResultsUrl.endsWith("/") - ? besOptions.besResultsUrl - : besOptions.besResultsUrl + "/"; - message = "Streaming Build Event Protocol to " + url + invocationId; + ? besOptions.besResultsUrl + invocationId + : besOptions.besResultsUrl + "/" + invocationId; + commandLineReporter.handle( + Event.info("Streaming Build Event Protocol to " + besResultsUrl)); } else { - message = - format( - "Streaming Build Event Protocol to %s build_request_id: %s " + "invocation_id: %s", - besOptions.besBackend, buildRequestId, invocationId); + besResultsUrl = null; + commandLineReporter.handle( + Event.info( + format( + "Streaming Build Event Protocol to %s build_request_id: %s " + + "invocation_id: %s", + besOptions.besBackend, buildRequestId, invocationId))); } - commandLineReporter.handle(Event.info(message)); BuildEventTransport besTransport = new BuildEventServiceTransport( @@ -253,7 +256,8 @@ public abstract class BuildEventServiceModule<T extends BuildEventServiceOptions pathConverter, commandLineReporter, besOptions.projectId, - keywords(besOptions, startupOptionsProvider)); + keywords(besOptions, startupOptionsProvider), + besResultsUrl); logger.fine("BuildEventServiceTransport was created successfully"); return besTransport; } diff --git a/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceTransport.java b/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceTransport.java index 42c363b49f..c19361e1fd 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceTransport.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceTransport.java @@ -28,6 +28,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; import com.google.common.base.Preconditions; +import com.google.common.base.Strings; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListeningExecutorService; import com.google.common.util.concurrent.SettableFuture; @@ -86,6 +87,7 @@ public class BuildEventServiceTransport implements BuildEventTransport { /** Max wait time between isStreamActive checks of the PublishBuildToolEventStream RPC. */ private static final int STREAMING_RPC_POLL_IN_SECS = 1; + private final String besResultsUrl; private final ListeningExecutorService uploaderExecutorService; private final Duration uploadTimeout; private final boolean publishLifecycleEvents; @@ -133,7 +135,8 @@ public class BuildEventServiceTransport implements BuildEventTransport { PathConverter pathConverter, EventHandler commandLineReporter, @Nullable String projectId, - Set<String> keywords) { + Set<String> keywords, + @Nullable String besResultsUrl) { this( besClient, uploadTimeout, @@ -148,7 +151,8 @@ public class BuildEventServiceTransport implements BuildEventTransport { commandLineReporter, projectId, keywords, - new JavaSleeper()); + new JavaSleeper(), + besResultsUrl); } @VisibleForTesting @@ -166,7 +170,8 @@ public class BuildEventServiceTransport implements BuildEventTransport { EventHandler commandLineReporter, @Nullable String projectId, Set<String> keywords, - Sleeper sleeper) { + Sleeper sleeper, + @Nullable String besResultsUrl) { this.besClient = besClient; this.besProtoUtil = new BuildEventServiceProtoUtil( buildRequestId, invocationId, projectId, command, clock, keywords); @@ -186,6 +191,7 @@ public class BuildEventServiceTransport implements BuildEventTransport { this.invocationResult = UNKNOWN_STATUS; this.uploadTimeout = uploadTimeout; this.sleeper = sleeper; + this.besResultsUrl = besResultsUrl; } public boolean isStreaming() { @@ -244,9 +250,18 @@ public class BuildEventServiceTransport implements BuildEventTransport { uploadComplete.get(uploadTimeout.toMillis(), MILLISECONDS); } report(INFO, UPLOAD_SUCCEEDED_MESSAGE); + if (!Strings.isNullOrEmpty(besResultsUrl)) { + report(INFO, "Build Event Protocol results available at " + besResultsUrl); + } + } catch (Exception e) { uploadComplete.cancel(true); reportErrorAndFailBuild(e); + if (!Strings.isNullOrEmpty(besResultsUrl)) { + report( + INFO, + "Partial Build Event Protocol results may be available at " + besResultsUrl); + } } } finally { shutdownFuture.set(null); |