Hi all, is it possible to write such a macro or a ...
# general
s
Hi all, is it possible to write such a macro or a plugin which loads some information into an env var and then other BUILD files could use that var, for example, add this env var as a tag for a docker image, pass this env var to tests, etc.?
b
I’m not sure I know the answer, but I can ask some clarifying questions: • Do you need it as an env var specifically? • What sort of information?
s
I want it to be available in a docker tag. It's information about the project version
I've seen this and I wonder if it's possible to inject env vars instead https://www.pantsbuild.org/docs/tagging-docker-images#Providing-additional-image-tags-with-a-plugin
We're using this information in BUILD files via
env("VERSION", "0.0.0")
in different places, not only in docker targets, so it's difficult to write plugins for every target we use it in
👍 1
b
One option might be a shell script called
.pants.bootstrap
adjacent to your
pants.toml
. This is executed before each pants run and, I believe, can set environment variables like
export VERSION=…
. That said, it sounds like you may already have that env var set, so can you pass it as
image_tags=[env(…)]
?
s
We have .env, but we have to run script to generate it before we execute pants commands
Does pants know about this .pants.bootstrap and automatically execute it?
b
Yes
s
Cool, I'll try it, thanks