Can I get env variables on a macro? :thinking_face...
# general
m
Can I get env variables on a macro? 🤔
h
Not currently. Macros are really simplistic, basically just replace the source code in BUILD files with your macro Build files can't import
os
because it would break caching You could use Pants 2.8's new "target generation" plugin hook! Which is how we go from python_tests to python_test for example. Any interest in that?
m
where can I see that?
tbh, I don't know what's the best path to take... My use case is: I have two dockerfiles, I want one of those to build on the CI, and the other to build locally, and I have an env variable "CI" there.
One of the solutions is add 2 fields on the `docker_image`:
skip_local
and
skip_ci
, which I can reuse later on
how can I skip
publish
and
package
after creating those two fields?
c
There’s a
skip_push
field on
docker_image
for the “don’t publish” part.
👍 1
m
Are you saying that for me to use on on the development of the plugin?
c
For skip package, I think perhaps use target tagging, and deselect based on that?
Copy code
# BUILD
docker_image(..., tags=["local"])
Then:
Copy code
./pants filter --tag-regex=-local :: | xargs ./pants package
Maybe.. ? 🙂
👇 1
h
You can use
--tag
globally, so you could do
./pants --tag=local package ::
and
./pants --tag=ci package ::
🙌 1
m
hmm, looks reasonable, I'm going to check if that works for me
c
Are you saying that for me to use on on the development of the plugin?
Uhm, not sure. Where ever it fits 😬
m
thanks
both 😎 👍
🙏 2
is there a negative for that? 🤔 --no-tag? 🤔
c
try
--tag=-local
?
I haven’t looked, just guessing wildly 😛