GoogleContainerTools / skaffold

Easy and Repeatable Kubernetes Development
https://skaffold.dev/
Apache License 2.0
15.03k stars 1.62k forks source link

jib builder: support for adding arguments to Maven on command line #3323

Open bjornmagnusson opened 4 years ago

bjornmagnusson commented 4 years ago

Need a way to be able to pass arbitrary arguments to Maven on command line, e.g for overwriting certain build properties. The current implementation does only support static arguments in skaffold.yaml but this is a bit different.

E.g. one situation I have faced is overriding location of docker registry when building images. When in office close to the docker registry hosted we use that one, but when outside office we have a need to be able to easily override that and point to another one, e.g. one hosted on local machine.

Expected behavior

Possible to add arbitrary arguments to jib builder when running skaffold dev/build/run

Actual behavior

Not possible to pass arguments

Information

apiVersion: skaffold/v1
kind: Config
build:
  artifacts:
  - image: startkit
    jib:
      project: :startkit-web-jar
      args:
      - -Pdocker
deploy:
  kubectl:
    manifests:
    - skaffold/k8s-*
portForward:
- resourceType: pod
  resourceName: startkit
  namespace: default
  port: 8080
  localPort: 8080
tejal29 commented 4 years ago

@bjornmagnusson you can specify registry override with --default-repo flag. That said, are there any other maven builder specific flag you need to pass to jib builder which are not part of the config?

bjornmagnusson commented 4 years ago

Thanks for that tips, but it doesn´t solve my use case.

Consider the following properties defined in pom.xml `

value1 value2 value3

`

I have a need to be able to override these (without manually editing skaffold.yaml) these in skaffold executions. The properties are project specific and not tied directly to properties in jib.

For example, using skaffold run with "--maven-args="-Dproperty1=whatever-value" "

zhuming commented 4 years ago

work around... :) use maven profile and specify profile in skaffold.yaml with

build:
  artifacts:
  - image: myartifactory.repo.com/hello/hw
    context: .
    jibMaven: {"profile":"your-favorite-profile"}
briandealwis commented 4 years ago

Two other approaches to consider: