I am seeing some unexpected behavior with build_args in the Docker plugin. If I specify build args directly in settings.build_args, the arg values will be split on commas into separate --build-args
values when I run a build. However, if I specify the args in the “environment” section of the step, then list those variable names in settings.build_args_from_env, the values will not be split on commas into separate build args, but each build arg is specified twice when I run a build.
This…
steps:
- name: build-args-split-on-commas
image: plugins/docker
settings:
build_args:
- MY_ARG=one,two,three
…results in a docker command like this when I run a build:
+ /usr/local/bin/docker build --rm=true -f path/to/Dockerfile -t abc123 . --pull=true --build-arg MY_ARG=one --build-arg two --build-arg three [...]
This…
steps:
- name: build-args-each-passed-twice
image: plugins/docker
environment:
MY_ARG_ONE: 'one1,one2,one3'
MY_ARG_TWO: 'two1,two2,two3'
settings:
build_args_from_env:
- MY_ARG_ONE
- MY_ARG_TWO
…results in the build args being passed correctly, but each one is passed twice:
+ /usr/local/bin/docker build --rm=true -f path/to/Dockerfile -t abc123 . --pull=true --build-arg MY_ARG_ONE=one1,one2,one3 --build-arg MY_ARG_ONE=one1,one2,one3 --build-arg MY_ARG_TWO=two1,two2,two3 --build-arg MY_ARG_TWO=two1,two2,two3 [...]