Build metadata
The Build Results UI reads specific metadata keys to fill fields such as Branch, Author, Task, and CI Host, and the matching feed filters. Aspect CLI tasks and Aspect Workflows CI runners set most of these automatically. For vanillabazel, the quickest setup is to have the Aspect CLI print them. Add one line to your .bazelrc:
.bazelrc
aspect setup workspace-data for the keys it emits and how it composes with your own.
To set the keys yourself, without the Aspect CLI or for keys it doesn’t cover, use Bazel’s
—build_metadata
or
—workspace_status_command
flags. The UI reads a key from either source.
Recommended keys
Workspace status command
To set other keys, or to work without the Aspect CLI, write a--workspace_status_command script that generates them from your CI environment variables.
Create a script:
workspace_status.sh
.bazelrc or specify it via the command line:
Build metadata flags
Set the same keys with--build_metadata flags instead of, or alongside, a workspace status script.
Aspect CLI tasks
Aspect CLI tasks set theASPECT_TASK_* keys themselves. To change the task name the UI shows,
pass --task:name or --task:friendly-name to the task. To add another key to every task’s
invocations, append a --build_metadata flag in config.axl, as in the ALLOW_ENV example below.
Redacted environment variables
The Build Results UI redacts environment variables in the command line and options it displays, since flags can carry secrets. To display specific variables, list them in theALLOW_ENV key.
Set the key in your workspace status script or with a build metadata flag. The value is a comma-separated list of environment variable names or patterns. If both set it, the build metadata value wins.
Example using build metadata
Example using workspace status
Example using config.axl
.aspect/config.axl
Bazel flags for the deeper views
Bazel’s defaults omit much of the data the Build Results UI’s deeper views are built from. The profile is slimmed and has no target labels, artifact listings come back empty, and the execution log, the source for per-target dependencies, is never produced. Enable the following flags to populate the Timing tab’s profile views, the Artifacts tab, and target dependency expansion. The execution log and profile reach the UI through the remote cache, so the build also needs a gRPC--remote_cache.
Workflows 6.0 or later is required. On 5.18 the flags are harmless but have
nothing to populate: the legacy UI has no Artifacts tab or dependency expansion.
See the .
On a self-hosted Aspect Enterprise deployment, the Artifacts tab can list a target’s full
output set instead of its important outputs, which is a deployment setting. See
.
Using .bazelrc
Add the flags to your workspace .bazelrc. Scoping them to a ci config keeps
the extra profiling work off local developer builds:
.bazelrc
--config=ci on CI invocations. To apply the flags everywhere,
including local builds, drop the :ci suffix and use plain common lines.
Using .aspect/config.axl
If you use the Aspect CLI, set the flags in .aspect/config.axl instead. This
applies them only when the CI environment variable is set, so no --config=ci
plumbing is needed in your pipeline:
.aspect/config.axl
Measuring the overhead
The cost of these flags depends on the shape of your build: the number of targets, the size of the output set, and how much of the build is already cached. Enable them on a branch and use the UI’s Compare page to measure two runs of the same task against each other. If the overhead is too high, drop--legacy_important_outputs first. The profiling flags are the cheapest to keep.
