Gregg
Gregg

Reputation: 499

Bazel: How to access workspace status variables in Skylark?

I'm using the --workspace_status_command with stable status variables similarly to the Kubernetes test-infra usage.

I would like to expose the STABLE_* variables to custom Skylark rules. How should I do that?

Upvotes: 3

Views: 2381

Answers (1)

kevingessner
kevingessner

Reputation: 18985

rules_docker supports stamping from the workspace status files. It looks like it uses ctx.info_file and ctx.version_file to access them: https://github.com/bazelbuild/rules_docker/blob/4d8ec6570a5313fb0128e2354f2bc4323685282a/container/layer_tools.bzl#L83

They aren't in the published docs but the Bazel source code seems to show that those are the right thing: https://github.com/bazelbuild/bazel/blob/0.12.0/src/main/java/com/google/devtools/build/lib/analysis/skylark/SkylarkRuleContext.java#L987-L1011

Upvotes: 4

Related Questions