Configuring the Bitrise Build Cache for Bazel in local environments
You can use the Bitrise Build Cache for Bazel on any machine: you just need to create a bitrise.bazelrc configuration file that includes the required configuration for the cache endpoints.
-
Select your Bitrise workspace and go to Build Cache.
-
Click New connection.
-
Select Other CI provider and then select your build tool from the dropdown menu.

-
Click .

-
Enter a name and set it to never expire.
-
Copy the keys and values of the two variables.
-
Set the variables as Environment Variables in your local configuration.
export BITRISE_BUILD_CACHE_WORKSPACE_ID=<workspace ID> export BITRISE_BUILD_CACHE_AUTH_TOKEN=<token>
-
Download the CLI and install it in a temporary location. You will only need to use it to activate the build cache once, or if any of the settings change.
curl --retry 5 -sSfL 'https://raw.githubusercontent.com/bitrise-io/bitrise-build-cache-cli/main/install/installer.sh' | sh -s -- -b /tmp/bin -d
-
Activate the Bitrise Build Cache.
There are a couple of flags you can use to control the configuration, but we recommend these defaults:
/tmp/bin/bitrise-build-cache activate bazel --cache --cache-push=false
Pulling from cache
We recommend only pulling artifacts from the cache to avoid accidentally sharing incorrect cache data due to file modifications during a build.
For the full list of flags check the CLI’s
/tmp/bin/bitrise-build-cache activate bazel --helpcommand. -
If you have Remote Build Execution enabled for your workspace, you can also use it locally by adding the
--rbeflag.Enabling RBE locally
You will need to have the workers set up for your workspace, and the pool configuration in your repository’s
.bazelrcfile before enabling RBE locally! -
Optionally, add your repository URL in your repository’s root
.bazelrcfile.We recommend doing this to be able to identify your local builds.
Replace the URL
Make sure to replace the placeholder URL in the command with your own!
build --remote_header='x-repository-url=https://github.com/bazelbuild/bazel.git' build --bes_header='x-repository-url=https://github.com/bazelbuild/bazel.git'
That's it! You can now run any bazel commands and take advantage of the Bitrise Build Cache. You can check the invocation details through the link printed during builds:
