Bazelregistry
| source | condition | target |
|---|---|---|
✔ | ✔ | ✗ |
Description
The bazelregistry resource reads a module’s metadata.json from a Bazel registry (the Bazel Central Registry by default) and returns a published version.
- source
Returns the version matching
versionfilter.- condition
Checks that the version exists in the registry.
- target
Not supported - a target fails with
target not supported for the plugin bazelregistry. To write the version into aMODULE.bazel, usebazelmod.
Note | An scm attached to a condition is ignored, with a warning (the lookup is always remote). |
Parameters
| Name | Type | Description | Required |
|---|---|---|---|
| module | string | Module specifies the Bazel module name to query from the registry compatible:
example:
| |
| url | string | URL specifies the custom registry URL (defaults to Bazel Central Registry) compatible:
default: https://raw.githubusercontent.com/bazelbuild/bazel-central-registry/main/modules/{module}/metadata.json example:
remarks:
| |
| versionfilter | object | VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest. compatible:
default: kind: latest | |
| kind | string | specifies the version kind such as semver, regex, or latest | |
| pattern | string | specifies the version pattern according the version kind for semver, it is a semver constraint for regex, it is a regex pattern for time, it is a date format | |
| regex | string | specifies the regex pattern, used for regex/semver and regex/time. Output of the first capture group will be used. | |
| replaceall | object | replaceAll applies a regex replacement to version strings before filtering. This is useful for transforming versions (e.g., curl-8_15_0 to curl-8.15.0) before regex extraction. | |
| strict | boolean | strict enforce strict versioning rule. Only used for semantic versioning at this time |
module is mandatory; omitting it aborts the run with wrong spec content, preceded by bazelregistry module undefined.
versionfilterDefaults to
kind: latest. See the "Version Filtering" page.
Custom registries
url points at a private registry. It is a template, not a base URL, it must contain the {module} placeholder, which is replaced with the module name:
spec:
module: rules_python
url: https://mycompany.example.com/bazel-registry/modules/{module}/metadata.jsonThe default is the Bazel Central Registry:
https://raw.githubusercontent.com/bazelbuild/bazel-central-registry/main/modules/{module}/metadata.jsonExample
sources:
rules_python:
name: Get latest version of Bazel module rules_python
kind: bazelregistry
spec:
module: rules_python
versionfilter:
kind: semver
pattern: '>=0.25.0'