GoogleContainerTools / skaffold

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

Jib build failing in multi-module gradle project #7902

Closed hpuac closed 2 years ago

hpuac commented 2 years ago

Skaffold tries to run the following command during the Jib build: gradle _skaffoldFailIfJibOutOfDate -Djib.requiredVersion=1.4.0 :_jibSkaffoldFilesV2 But the _jibSkaffoldFilesV2 task gets executed on the root project. In a multi-module gradle project this task does not exist on the root project.

Expected behavior

I would expect Skaffold to support the Jib build in a multi-module gradle project.

Actual behavior

Skaffold is failing during the Jib build in a multi-module gradle project.

Information

apiVersion: skaffold/v2beta29
kind: Config
metadata:
  name: hello-jib
build:
  artifacts:
  - image: hello-jib
    jib:
      type: gradle
    context: .
  local:
    push: false
deploy:
  kubectl:
    manifests:
    - k8s/deploy.yaml

Steps to reproduce the behavior

  1. Clone the Jib repository and open the multi-module example
  2. Change directory into one of the sub-modules like the hello-service
  3. Run skaffold build -v debug or run gradle _skaffoldFailIfJibOutOfDate -Djib.requiredVersion=1.4.0 :_jibSkaffoldFilesV2 directly
  4. The command will fail with the error Task '_jibSkaffoldFilesV2' not found in root project 'jib-multimodule'.
araminian commented 2 years ago

This problem can be fixed by change the context to tell Skaffold to use gradle file in root level and specifying the name of the project you want to build(name of the project can be found by running gradle projects).

apiVersion: skaffold/v2beta29
kind: Config
metadata:
  name: hello-jib
build:
  artifacts:
  - image: hello-jib
    jib:
      type: gradle
      project: [PROJECT-NAME]
    context: ..
  local:
    push: false
deploy:
  kubectl:
    manifests:
    - k8s/deploy.yaml