sourceconditiontarget

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 a MODULE.bazel, use bazelmod.

Note
An scm attached to a condition is ignored, with a warning (the lookup is always remote).

Parameters

NameTypeDescriptionRequired
modulestring

Module specifies the Bazel module name to query from the registry

compatible:

  • source
  • condition

example:

  • rules_go
  • rules_python
  • gazelle
urlstring

URL specifies the custom registry URL (defaults to Bazel Central Registry)

compatible:

  • source
  • condition

default: https://raw.githubusercontent.com/bazelbuild/bazel-central-registry/main/modules/{module}/metadata.json

example:

  • https://raw.githubusercontent.com/bazelbuild/bazel-central-registry/main/modules/{module}/metadata.json
  • https://mycompany.com/bazel-registry/modules/{module}/metadata.json

remarks:

  • The URL must contain {module} placeholder which will be replaced with the module name
  • If not specified, defaults to the official Bazel Central Registry
versionfilterobject

VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest.

compatible:

  • source

default: kind: latest

    kindstringspecifies the version kind such as semver, regex, or latest
    patternstringspecifies 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
    regexstringspecifies the regex pattern, used for regex/semver and regex/time. Output of the first capture group will be used.
    replaceallobjectreplaceAll 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.
    strictbooleanstrict 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.

versionfilter

Defaults 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.json

The default is the Bazel Central Registry:

https://raw.githubusercontent.com/bazelbuild/bazel-central-registry/main/modules/{module}/metadata.json

Example

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'