Is there a way to use pants to create an environme...
# general
s
Is there a way to use pants to create an environment variable that can be used in subsequent calls? For example I am building a tarball that needs to point to a docker image which uses a bash script to come up with that value (like branch name + date). Thank you!
Like could I export it from a
shell_command
and then import it to another command?
e
Not quite what you are looking for, but https://www.pantsbuild.org/stable/docs/using-pants/key-concepts/options#pantsbootstrap-file may be able to cover your use case. Its a place to run arbitrary bash code that is sourced before each pants run. So you could generate your environment variables there and then they will be available throughout your pants uses
s
yeah! that could work. But I feel like there could be a more pant-sy way to pass the value that isn’t just a file
In that doc page, they talk about
--scope
and I know I can also use f”{env(‘BLAH’)” so it feels like I could write to a file, I just need to know how to get it back out 😕
The goal is pretty similar to vcs_version so I’ll look into that too
@elegant-florist-94385 FYI, seeing this was the blog posted way to do this, was helpful reassurance this is the preferred approach https://www.pantsbuild.org/blog/2024/04/27/simple-versioning-with-git-tags --- even though it didn’t feel pant-sy