- Build Event Identifier: Depending on the kind of build event, it might be an opaque string or structured information revealing more about the build event. A build event identifier is unique within a build.
-
Children: A build event may announce other build events, by including
their build event identifiers in its children
field.
For example, the
PatternExpandedbuild event announces the targets it expands to as children. The protocol guarantees that all events, except for the first event, are announced by a previous event. -
Payload: The payload contains structured information about a build event,
encoded as a protocol buffer message specific to that event. Note that the
payload might not be the expected type, but could be an
Abortedmessage if the build aborted prematurely.
Build event graph
All build events form a directed acyclic graph through their parent and child relationship. Every build event except for the initial build event has one or more parent events. Please note that not all parent events of a child event must necessarily be posted before it. When a build is complete (succeeded or failed) all announced events will have been posted. In case of a Bazel crash or a failed network transport, some announced build events may never be posted. The event graph’s structure reflects the lifecycle of a command. Every BEP graph has the following characteristic shape:- The root event is always a
BuildStartedevent. All other events are its descendants. - Immediate children of the BuildStarted event contain metadata about the command.
- Events containing data produced by the command, such as files built and test
results, appear before the
BuildFinishedevent. - The
BuildFinishedevent may be followed by events containing summary information about the build (for example, metric or profiling data).
Consuming Build Event Protocol
Consume in binary format
To consume the BEP in a binary format:-
Have Bazel serialize the protocol buffer messages to a file by specifying the
option
--build_event_binary_file=/path/to/file. The file will contain serialized protocol buffer messages with each message being length delimited. Each message is prefixed with its length encoded as a variable length integer. This format can be read using the protocol buffer library’sparseDelimitedFrom(InputStream)method. - Then, write a program that extracts the relevant information from the serialized protocol buffer message.
Consume in text or JSON formats
The following Bazel command line flags will output the BEP in human-readable formats, such as text and JSON:Build Event Service
The Build Event Service Protocol is a generic gRPC service for publishing build events. The Build Event Service protocol is independent of the BEP and treats BEP events as opaque bytes. Bazel ships with a gRPC client implementation of the Build Event Service protocol that publishes Build Event Protocol events. One can specify the endpoint to send the events to using the--bes_backend=HOST:PORT flag. If your backend uses gRPC,
you must prefix the address with the appropriate scheme: grpc:// for plaintext
gRPC and grpcs:// for gRPC with TLS enabled.
Build Event Service flags
Bazel has several flags related to the Build Event Service protocol, including:--bes_backend--[no]bes_lifecycle_events--bes_results_url--bes_timeout--bes_instance_name
Authentication and security
Bazel’s Build Event Service implementation also supports authentication and TLS. These settings can be controlled using the below flags. Please note that these flags are also used for Bazel’s Remote Execution. This implies that the Build Event Service and Remote Execution Endpoints need to share the same authentication and TLS infrastructure.--[no]google_default_credentials--google_credentials--google_auth_scopes--tls_certificate--[no]tls_enabled