Closed suzaku closed 1 year ago
hi @suzaku, I'm not sure I understand what the exact issue is. As far as I understand, the two ways you mentioned should work so I'm quite puzzled.
I have tried these two pipelines and they both work as expected:
env:
MY_VAR: value1
steps:
- label: test1
env:
MY_VAR_2: value2
command: 'echo $${MY_VAR} and $${MY_VAR_2}'
plugins:
- docker-compose#v4.7.0:
env: [ MY_VAR, MY_VAR_2 ]
run: tests
As well as propagate environment:
env:
MY_VAR: value1
steps:
- label: test1
env:
MY_VAR_2: value2
command: 'echo $${MY_VAR} and $${MY_VAR_2}'
plugins:
- docker-compose#v4.7.0:
propagate-environment: true
run: tests
The one thing I can say is that your environment definition appears to be wrong (as it is supposed to be a dictionary/map, not a list)
So it only works for run
, right? Is there a env
passing mechanism for build
?
Oh, you are running builds.
Docker has no way to pass environment variables for build steps. You need to use args instead... They are similar, but not exactly the same as they have different semantics (args can be used during builds but not available during runs). To be able to have both you need to do a little trick in you dockerfile
No, the environment variables are for interpolation in the docker-compose.yml
, not for the docker build itself.
Since there's no way to build and push multiple tags at the same plugin configuration, I'm trying to add multiple services in the docker-compose.yml
and specify multiple services in build
. To differentiate them, I want to use environment variables and interpolation.
Could you share some part of your docker compose file to understand exactly where you are using the environment variables then?
Never mind. I will just write my own custom script and use environment variables.
I've tried setting
env
in bothstep
level andplugin
level with no luck:I have also tried setting
propagate-environment: true
for the plugin.But I get warnings like
The MY_VAR variable is not set. Defaulting to a blank string.
every time.The version I use is v4.7.0.