Buildless + Bazel

Using Buildless remote build caching with Bazel


Support for Bazel is early

It largely works but we will be adding better support for Bazel soon.

Bazel, the open source variant of Google's internal build system ("Blaze"), is very good at remote caching. Bazel takes a strict approach to hermeticity and build graph resolution, which helps make sure build caching is maximally effective.

You can use Buildless as a drop-in remote build cache with Bazel. To set things up, follow the directions below.

See it in action

Here's a demo of a build which uses Buildless with Bazel, compared with one that doesn't:

Testing: Same machine/hardware, same project, same commit, same command, same options (except for Buildless). Disk cache enabled.

Obtain your account and API key

Before you configure Bazel with Buildless, you'll need to setup your account and obtain your API key. You can sign up for Buildless here. To locate your API key, it depends which kind of key you want to use:

  • For individual users: Your API key is located in the welcome email and in your user settings, accessed from the Buildless Console.
  • For tenant users who wish to authorize an org-level cache (with no specific user), access your org API key in the Buildless Console at Tenant → Settings → Integration.

Authorizing your environment

The easiest and most secure way to use Buildless is via the environment variables and CLI config files. These techniques for configuring the cache keep your API key out of your source code.

Once you obtain your API key, set it in your environment via BUILDLESS_APIKEY:

echo "export BUILDLESS_APIKEY=..." >> ~/.bashrc


Buildless with Bazel does not yet support config files

The best way to authorize the cache is with a config file stored in your project, user directory, or globally on your system; this keeps your API key out of your environment, too, where other tools can access it.

Our Bazel integration does not yet support this feature, but it will soon.

Configuring Bazel to use Buildless

Configuring the build cache itself is easy and quick. Add the following to your .bazelrc:

build --remote_cache=

Unfortunately, the .bazelrc file does not support environment variables. The recommended practice is to list your API key in user-level settings. For example:

build --remote_header=x-api-key=...

Code sample

Check out our code samples, including our code sample for Bazel/Java/Buildless.