Skip to content

Commit a822e6d

Browse files
committed
Always send hostname and username in BuildStarted BES message
Per a review comment (bazelbuild#27120 (comment)) on bazelbuild#27120, we here propose to send the hostname and username via the BuildStarted BES message rather than the workspace status BES message.
1 parent f56e927 commit a822e6d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/main/java/com/google/devtools/build/lib/buildeventstream/proto/build_event_stream.proto

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,12 @@ message BuildStarted {
396396

397397
// The process ID of the Bazel server.
398398
int64 server_pid = 8;
399+
400+
// The short hostname of the machine where the build is running.
401+
string host = 10;
402+
403+
// The username of the user who started the build.
404+
string user = 11;
399405
}
400406

401407
// Configuration related to the blaze workspace and output tree.

src/main/java/com/google/devtools/build/lib/buildtool/buildevent/BuildStartingEvent.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import com.google.devtools.build.lib.buildtool.BuildRequest;
2929
import com.google.devtools.build.lib.runtime.CommandEnvironment;
3030
import com.google.devtools.build.lib.runtime.CommandLineEvent;
31+
import com.google.devtools.build.lib.util.NetUtil;
32+
import com.google.devtools.build.lib.util.UserUtils;
3133
import com.google.protobuf.util.Timestamps;
3234
import javax.annotation.Nullable;
3335

@@ -116,7 +118,9 @@ public final BuildEventStreamProtos.BuildEvent asStreamProto(BuildEventContext c
116118
.setOptionsDescription(request().getOptionsDescription())
117119
.setCommand(request().getCommandName())
118120
.setServerPid(ProcessHandle.current().pid())
119-
.setWorkingDirectory(pwd());
121+
.setWorkingDirectory(pwd())
122+
.setHost(NetUtil.getCachedShortHostName())
123+
.setUser(UserUtils.getUserName());
120124
if (workspace() != null) {
121125
started.setWorkspaceDirectory(workspace());
122126
}

0 commit comments

Comments
 (0)