Search code examples
bazelstarlark

Does bazel theoretically allow http requests inside bazel build rules?


Is there any possibility to write http requests in starlark build rule or via some executable invoked by ctx.actions.run ?

I know it can be done with bazel test (inside test runners), but can it be done in build phase? I know this goes against network sandboxing (but lets say we turn it off)


Solution

  • You can set execution_requirements to include requires-network.

    Some notes:

    • The network requests are only within actions, they can't be run from Starlark itself
    • Bazel won't know to rerun actions that depend on network requests if the remote information has changed. There would need to be a way to make an action always run, which hasn't been decided on: https://github.com/bazelbuild/bazel/issues/3041