Keep Bazel version consistent with Bazelisk


Bazel is a build system, which allows you to build and test source code written in many programming languages and other things such as Protocol Buffer. Keeping bazel version consistent across developer machines and continuous integration machines is challenging. Often, a continuous integration machine is running an older version of bazel. The bazel installation on the CI machine needs to be managed by someone who has privilege to install software.


Bazel provides a default way to wrap around the real Bazel binary on a machine. If tools/bazel exists in a repository, Bazel will execute the tools/bazel instead of the real bazel binary. tools/bazel can then ensure the bazel binary installed on the machine is the right version.


If writing the tools/bazel script is too much work, using Bazelisk is another option. The idea is to check in both the linux binary and the macos binary of bazelisk into the repository so that developer and the CI system can execute bazelisk without talking to the internet. For those using Windows, you can check in the window binary as well.

comments powered by Disqus

Copyright © 2021 Kenneth Feng. All Rights Reserved