knative / build

A Kubernetes-native Build resource.
Apache License 2.0
575 stars 159 forks source link

Error: unknown flag when using --build-arg in buildtemplate #565

Closed guyos closed 5 years ago

guyos commented 5 years ago

/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

  1. 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
  2. apply the build template
  3. apply a build setting the variables

Additional Info

cristina-grosu commented 5 years ago

Hi guys,

I have the same issue.

ankur47 commented 5 years ago

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
imjasonh commented 5 years ago

@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.