bazelisk Command Reference
Run the exact Bazel version a repo pins, on every machine.
bazelisk is a launcher that picks the right Bazel version per repository and downloads it on demand. It is the recommended way to invoke Bazel, especially in CI.
What it does
bazelisk reads the .bazelversion file (or USE_BAZEL_VERSION) to decide which Bazel release to run, downloads it if needed, and forwards all arguments to it. This guarantees every developer and runner uses the same Bazel version.
Common flags and usage
- bazelisk build|test|run ...: forwards args to the pinned Bazel
- .bazelversion file: pins the version per repository
- USE_BAZEL_VERSION=X: override the version for one invocation
- Install as the bazel binary so bazel transparently uses it
Example
shell
- name: Build with pinned Bazel
run: |
echo "7.4.1" > .bazelversion # usually already committed
bazelisk build --config=ci //...In CI
Invoke bazelisk (or alias bazel to it) so the runner uses exactly the version in .bazelversion, eliminating works-on-my-machine version skew between local and CI builds.
Key takeaways
- bazelisk runs the Bazel version pinned in .bazelversion.
- It downloads the right release on demand and forwards all arguments.
- Using it in CI removes Bazel version skew between machines.
Related guides
bazel build Command ReferenceReference for bazel build in CI/CD: build targets and patterns hermetically, scope with target syntax, and ac…
bazel test Command ReferenceReference for bazel test in CI/CD: run test targets with caching, surface failing logs with --test_output=err…
bazel query Command ReferenceReference for bazel query in CI/CD: inspect the dependency graph to find reverse deps, scope affected targets…