knative / build

A Kubernetes-native Build resource.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

guyos opened this issue · comments

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

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

Additional Info

Hi guys,

I have the same issue.

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

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