feat: added env variable passing to labgrid_run
Added the ability to pass environment variables down into binaries being ran with labgrid_run.
There is a new test target in e2e/docker:
hello_world_test - a labgrid_genrule that uses labgrid_run and ape:printenv that prints out 'HELLO' env var that is provided as part of the cmd.
There are two main approaches to specifying environment variables:
- Providing
--env MY_ENV=MY_VALUE
in the cmd for labgrid_run. - Specifying just the environment variable key and not the value like
--env MY_ENV
will attempt to resolve the value using the hosts environment.
For example using this target:
labgrid_run(
name = "hello_world",
srcs = ["@ape//ape:printenv"],
cmd = "--env HELLO -- $(location @ape//ape:printenv) HELLO > $@",
outs = ["hello_world.log"],
platform = ":platform",
tags = [
"manual",
"requires-docker",
],
)
you would need to specify the environment variable as part of the cli:
bazel build //docker:hello_world --action_env HELLO=MY_OTHER_VALUE
This would result in HELLO being set to 'MY_OTHER_VALUE'.
Edited by Jordan Bonser