https://pantsbuild.org/ logo
#general
Title
# general
m

modern-wolf-36228

12/08/2021, 3:38 PM
Can I get env variables on a macro? 🤔
h

hundreds-father-404

12/08/2021, 3:48 PM
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

modern-wolf-36228

12/08/2021, 3:51 PM
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

curved-television-6568

12/08/2021, 4:37 PM
There’s a
skip_push
field on
docker_image
for the “don’t publish” part.
👍 1
m

modern-wolf-36228

12/08/2021, 4:39 PM
Are you saying that for me to use on on the development of the plugin?
c

curved-television-6568

12/08/2021, 4:40 PM
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

hundreds-father-404

12/08/2021, 4:41 PM
You can use
--tag
globally, so you could do
./pants --tag=local package ::
and
./pants --tag=ci package ::
🙌 1
m

modern-wolf-36228

12/08/2021, 4:43 PM
hmm, looks reasonable, I'm going to check if that works for me
c

curved-television-6568

12/08/2021, 4:43 PM
Are you saying that for me to use on on the development of the plugin?
Uhm, not sure. Where ever it fits 😬
m

modern-wolf-36228

12/08/2021, 4:43 PM
thanks
both 😎 👍
🙏 2
is there a negative for that? 🤔 --no-tag? 🤔
c

curved-television-6568

12/08/2021, 4:46 PM
try
--tag=-local
?
I haven’t looked, just guessing wildly 😛
5 Views