I have a team member trying to access some environ...
# general
I have a team member trying to access some environment variables within pytest code but we're unable to find the environment variables inside of the sandbox that 1.30 operates in. Is there a way to do something like
export PANTS_PYTEST_VAR1=test
and have the python code see that env var?
I see that 2.12 added some neat functionality which is a goal to upgrade to, but hoping there's a simple solution for 1.30 while we work through the upgrade to 2.12
It looks like the option is
(Or pants.toml it with
[test] extra_env_vars = [ ... ]
): https://github.com/pantsbuild/pants/blob/674df55a3dda870e78997965e617993b9d10d2eb/src/python/pants/core/goals/test.py#L195-L244
That's if using v2 rules, The v1 handling should just let env vars be read without any configuration.
this would be using v2
Ok, that should do it then. And it looks like that's still the same setting in modern Pants 2.x.
I tried
./pants test --test-extra-env-vars VAR=v target::test
and pants told me that
was not recognized.
How about
./pants test --extra-env-vars VAR=v target::test
Ah, right. You need
./pants test --extra-env-vars=VAR=v target::test
All pants flags unfortunately need
Oddly enough this is the help advanced menu
I would've expected it to list the global options too
./pants --v2
right? You said you were using
Yeah, I have v1 disabled in the pants.toml file
What is the exact Pants version?
Try 1.30.4 or 1.30.5rc1.
Those are 2 latest 1.30.x
The code I linked was 1.30.x HEAD.
Looks like backported to 1.30.2rc0 (9/23/2020)
Oh gotcha, i'm trying .4 right now to see if that works better
Yeah, .4 looks like it will have that extra arg like you mentioned. I'll give it a go!
Sweet, that let me pass through the a dummy env var, I can easily add what I actually need from there. Thanks!