HermetiqDocsOpen dashboard
Configuration

Configure Bazel for Hermetiq

Use project-scoped values from Quickstart for BEP ingestion, authentication, profiles, metadata, remote cache, and build grouping.

Use the generated values from your project’s Quickstart page

Your source of truth

Open Quickstart inside the matching Cloud or customer-managed dashboard for the project you are configuring. It provides the correct project ID, service endpoints, credential-helper mappings, and optional cache configuration. In Hermetiq Cloud, the credential helper is a file you download from Quickstart and commit. In customer-managed deployments, obtain the helper through the administrator’s approved provisioning path.

BEP configuration

The core configuration sends BEP events to Hermetiq and associates them with your project. Quickstart supplies the credential-helper host mappings used to authenticate the relevant Hermetiq endpoints; in Hermetiq Cloud they point at %workspace%/tools/hermetiq-credential-helper, and in a customer-managed deployment at the administrator-provided helper.

.bazelrc · structure only
build:hermetiq --bes_instance_name=<PROJECT_ID>
build:hermetiq --bes_backend=<BEP_ENDPOINT>
build:hermetiq --bes_timeout=120s
build:hermetiq --bes_results_url=<RESULTS_URL>
build:hermetiq --bes_upload_mode=wait_for_upload_complete

When entries use the build:hermetiq prefix, activate them with --config=hermetiq. Quickstart can instead generate global build entries if that better fits your Bazel configuration model.

Profile configuration

These Bazel flags produce the profile data used by profile trends, critical-path analysis, parallelism analysis, and profile-derived insights:

.bazelrc
build:hermetiq --generate_json_trace_profile
build:hermetiq --experimental_profile_include_primary_output
build:hermetiq --experimental_profile_include_target_label
build:hermetiq --noslim_profile

Build metadata

Add commit, repository, branch, role, or other stable metadata so builds can be filtered and compared in context. Quickstart documents two supported patterns:

  • Pass --build_metadata values on the Bazel command line.
  • Use a workspace-status script and --workspace_status_command.

Bazel does not perform shell substitution inside .bazelrc, so dynamic values belong in the command line or a script.

CI configuration

In Hermetiq Cloud, CI already has the committed helper. Give CI its own credentials: add a dedicated CI member to the project, such as a bot account with the Builder role, sign in as that member, and issue credentials in Quickstart. Store the client ID and secret as two CI secrets and expose them to the Bazel step as HERMETIQ_M2M_CLIENT_ID and HERMETIQ_M2M_CLIENT_SECRET. In a customer-managed deployment, provide the administrator’s helper to CI from the secret manager instead.

Give each logical CI run a stable build request ID and attach repository context as build metadata.

CI shell · replace placeholders
# Hermetiq Cloud: the committed helper reads the CI member's credentials
# from these two variables. Set them from your CI secret manager.
export HERMETIQ_M2M_CLIENT_ID=<FROM_CI_SECRETS>
export HERMETIQ_M2M_CLIENT_SECRET=<FROM_CI_SECRETS>

BUILD_ID="${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
bazel test //... --config=hermetiq \
  --build_request_id="${BUILD_ID}" \
  --build_metadata=ROLE=CI \
  --build_metadata=REPO_URL=<REPOSITORY_URL> \
  --build_metadata=COMMIT_SHA=<COMMIT_SHA> \
  --build_metadata=BRANCH_NAME=<BRANCH_NAME>
  • GitHub Actions commonly derives the ID from GITHUB_RUN_ID and GITHUB_RUN_ATTEMPT.
  • Buildkite, Jenkins, and other systems should use their stable pipeline/build identifier plus a retry or attempt value.
  • Do not print HERMETIQ_M2M_CLIENT_SECRET or the helper’s output in job logs.
  • Builds from forks usually can’t read your CI secrets, so the helper fails with “no credentials”. Run those builds without --config=hermetiq.
  • If you issue new credentials for the CI member, update both secrets.
  • Use the same --build_request_id for related build and test commands in one logical CI run.

Remote cache

Projects using Hermetiq’s remote cache receive the endpoint and instance value in Quickstart. The remote instance name must match the project identity carried by the machine credential.

.bazelrc · structure only
build:hermetiq --remote_instance_name=<PROJECT_ID>
build:hermetiq --remote_cache=<REMOTE_CACHE_ENDPOINT>

bb_clientd (optional)

bb_clientd is Buildbarn’s client daemon. It runs on a developer machine between Bazel and your remote cache: Bazel talks to it over a local socket, and it talks to the cache. It adds two things Bazel doesn’t do on its own:

  • A local copy of every file it fetches. After bazel clean, a branch switch, or in a second checkout, those files come from your disk instead of the network.
  • Bazel’s output service (Bazel 7.2 and later): bazel-out lives in bb_clientd’s file system, and each output downloads only when something reads it.

Quickstart’s optional bb_clientd step generates these settings for your project. This section explains them.

When it helps

It helps most on developer machines that rebuild in several checkouts or output bases. A CI runner that starts clean each time has nothing local to reuse. Ordinary incremental builds already reuse Bazel’s own outputs, and --disk_cache overlaps with the local copy. Siso, Chromium’s build tool, can use the local copy but not the output service; see the operator guide for what we measured.

Install and start it

The same commands work on Linux and macOS. They download the binary for your system and the default configuration from the same release:

Download bb_clientd
BB_CLIENTD_RELEASE=20261008T163232Z-ffb6815
BB_CLIENTD_OS="$(uname | tr A-Z a-z)"
case "$(uname -m)" in x86_64) BB_CLIENTD_ARCH=amd64 ;; aarch64|arm64) BB_CLIENTD_ARCH=arm64 ;; esac
mkdir -p "$HOME/.local/bin" "$HOME/.config/bb_clientd"
curl -fL "https://github.com/buildbarn/bb-clientd/releases/download/$BB_CLIENTD_RELEASE/bb_clientd.${BB_CLIENTD_OS}_$BB_CLIENTD_ARCH" -o "$HOME/.local/bin/bb_clientd"
curl -fL "https://raw.githubusercontent.com/buildbarn/bb-clientd/$BB_CLIENTD_RELEASE/configs/bb_clientd.jsonnet" -o "$HOME/.config/bb_clientd/bb_clientd_defaults.jsonnet"
chmod +x "$HOME/.local/bin/bb_clientd"

Write the configuration below first, then start bb_clientd. It runs in the terminal until you stop it with Ctrl+C:

Start bb_clientd
mkdir -p "${XDG_CACHE_HOME:-$HOME/.cache}/bb_clientd/ac/persistent_state" "${XDG_CACHE_HOME:-$HOME/.cache}/bb_clientd/cas/persistent_state" "${XDG_CACHE_HOME:-$HOME/.cache}/bb_clientd/outputs" "$HOME/bb_clientd"
OS="$(uname)" XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" "$HOME/.local/bin/bb_clientd" "$HOME/.config/bb_clientd/bb_clientd.jsonnet"

On macOS it mounts its files with NFSv4, so macFUSE isn’t needed. On Linux you can instead install the .deb from its releases and run systemctl --user enable --now bb_clientd. Either way, ls ~/bb_clientd then shows cas, outputs and scratch, and the log is in ~/.cache/bb_clientd/log.

Configure it

~/.config/bb_clientd/bb_clientd.jsonnet
// ~/.config/bb_clientd/bb_clientd.jsonnet
local defaults = import 'bb_clientd_defaults.jsonnet';
defaults {
  clusters:: { 'bb.<your-domain>': 'bb.<your-domain>' },
  grpcClient:: function(hostname, authorizationHeader, proxyURL)
    super.grpcClient(hostname, authorizationHeader, proxyURL) + { address: 'bb.<your-domain>:443', tls: { serverName: 'bb.<your-domain>' } },
  global+: { grpcForwardAndReuseMetadata: ['x-hermetiq-m2m-access-token'] },
  mount+: if std.extVar('OS') == 'Linux' then { fuse+: { allowOther: false } } else {},
}
  • clusters names your cache. Bazel puts that name in front of the instance name; bb_clientd uses it to pick the cache and strips it before forwarding, so the cache sees your project ID.
  • grpcClient connects on port 443 with TLS and names the server in the handshake. Some gateways reset connections that don’t. For a plaintext grpc:// cache, use its port and tls:: null instead.
  • grpcForwardAndReuseMetadata passes on the header Hermetiq Cloud’s credential helper sends, and reuses it to fetch files later until the token expires. If your helper sends authorization, leave this line out: that’s bb_clientd’s default.
  • On Linux, the mount is readable only by you unless /etc/fuse.conf has user_allow_other.

Point Bazel at it

Bazel picks a credential helper by host, and a socket has no host, so the cache’s helper would have to be named without one. Bazel then also uses it for every other host it contacts, such as the Bazel Central Registry or GitHub. This wrapper answers only for bb_clientd’s socket. Save it next to your project’s helper and make it executable:

tools/bb-clientd-credential-helper
#!/usr/bin/env bash
# tools/bb-clientd-credential-helper
# Bazel sends the address it needs credentials for as JSON on stdin.
# Answer only for bb_clientd's socket; every other host gets none.
case "$(cat)" in
  *'"unix:'*) exec "$(dirname "$0")/hermetiq-credential-helper" "$@" </dev/null ;;
  *) echo '{}' ;;
esac

Then add a bb-clientd group to user.bazelrc, and try-import %workspace%/user.bazelrc to your .bazelrc. A .bazelrc doesn’t expand ~, so write your home folder in full; Quickstart’s command does that for you.

user.bazelrc
# user.bazelrc: paths are yours, so this file stays out of git
build:bb-clientd --config=hermetiq
build:bb-clientd --remote_cache=unix:///home/<you>/.cache/bb_clientd/grpc
build:bb-clientd --remote_instance_name=bb.<your-domain>/<PROJECT_ID>
build:bb-clientd --credential_helper=%workspace%/tools/bb-clientd-credential-helper
build:bb-clientd --remote_bytestream_uri_prefix=bb.<your-domain>/<PROJECT_ID>
build:bb-clientd --experimental_remote_output_service=unix:///home/<you>/.cache/bb_clientd/grpc
build:bb-clientd --experimental_remote_output_service_output_path_prefix=/home/<you>/bb_clientd/outputs
  • --config=hermetiq keeps your build events and other settings; the lines after it point the cache at bb_clientd. Build events still go straight to Hermetiq.
  • --remote_bytestream_uri_prefix keeps links in the build events pointing at your cache, not the local socket, so Hermetiq can read profiles and other files.
  • The two output-service flags make bazel-out load on demand. Leave both out to use bb_clientd only as a local cache.

Check that it works

Build with --config=bb-clientd, run bazel clean, and build again. The second build reports remote cache hits, bazel-out points into ~/bb_clientd/outputs, and both builds appear in Hermetiq as usual. To count what bb_clientd served locally, enable its metrics endpoint as the operator guide shows.

Group related invocations

When a CI job runs multiple Bazel commands that belong to one logical build, pass the same --build_request_id to each invocation. Hermetiq can then group them into one build-level record.

CI example
# Example: use one ID for build and test invocations in the same CI run
BUILD_ID="${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"

bazel build //... --build_request_id="${BUILD_ID}"
bazel test  //... --build_request_id="${BUILD_ID}"
Last reviewedNovember 6, 2026