Error: unknown flag when using --build-arg in buildtemplate
guyos opened this issue · comments
guyos commented
/kind bug
Expected Behavior
Build argument is passed to Dockerfile and arg value is used in the build
Actual Behavior
Getting the following error when building...
Error: unknown flag: --build-arg A_TARGET
Usage:
executor [flags]
Flags:
--build-arg multi-arg type This flag allows you to pass in ARG values at build time. Set it repeatedly for multiple values.
...
Steps to Reproduce the Problem
- Create a buildtemplate that has a similar step to this where A_TARGET is an ARG in a Dockerfile
steps:
- name: build-and-push
image: gcr.io/kaniko-project/executor
args:
- --dockerfile=${DOCKERFILE}
- --destination=${IMAGE}
- --build-arg A_TARGET=green
- apply the build template
- apply a build setting the variables
Additional Info
cristina-grosu commented
Hi guys,
I have the same issue.
ankur47 commented
Create your build template as mentioned below
name: 'gcr.io/kaniko-project/executor:latest'
args:
- --dockerfile=${DOCKERFILE}
- --build-arg
- A_TARGET=green
- --build-arg
- B_TARGET=blue
- --destination=${IMAGE}
- --cache=true
Jason Hall commented
@ankur47's answer is correct, without being passed as separate items into args
, it's interpreted as one arg that includes a space, as if you'd passed executor "--build-arg A_TARGET=green"
instead of executor --build-arg A_TARGET=green
like you expect, and the tool requires.