Skip to content

Commit bf91d53

Browse files
dwsbazel-io
authored andcommitted
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. Closes bazelbuild#27421. PiperOrigin-RevId: 825070359 Change-Id: I6e8f2e13e90aa6276f629c1da630a5da8e2468e9
1 parent a31f548 commit bf91d53

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
@@ -388,6 +388,12 @@ message BuildStarted {
388388

389389
// The process ID of the Bazel server.
390390
int64 server_pid = 8;
391+
392+
// The short hostname of the machine where the build is running.
393+
string host = 10;
394+
395+
// The username of the user who started the build.
396+
string user = 11;
391397
}
392398

393399
// 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)