GoogleContainerTools / skaffold

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

Gradle wrapper is not detected reliably #9494

Closed sergeykad closed 3 months ago

sergeykad commented 3 months ago

Expected behavior

Skaffold will always use Gradle wrapper if present for Gradle + Jib build

Actual behavior

Gradle wrapper detected only in some scenarios.

File structure: +-------------------+ Project Root +-------------------+
+-- skaffold.yaml
+-- gradlew
+-- service1
+-- skaffold.yaml
+-- service2
+-- skaffold.yaml

+-------------------+

Unsupported scenarios:

  1. Skaffold executed in a module directory.
    cd service1
    skaffold run
    exec: "gradle": executable file not found in $PATH
  2. Skaffold executed in the root folder, but configuration refers a submodule.
    
    apiVersion: skaffold/v4beta11
    kind: Config

requires:

This issue makes it very awkward to use Skaffold with a multimodule Grale project.

Information

Skaffold version: 2.12.0 Operating system: Ubuntu 22.04.4 Installed via: curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && \ sudo install skaffold /usr/local/bin/

Logs

Skaffold executed from project's root without submodules

DEBU[0002] Running command: [java -version]              subtask=-1 task=Build
DEBU[0002] Using wrapper for gradlew: gradle             subtask=-1 task=Build
DEBU[0002] Running command: [/home/user/my-project/gradlew _skaffoldFailIfJibOutOfDate -Djib.requiredVersion=1.4.0 :file-system-manager:_jibSkaffoldFilesV2 -q --console=plain]  subtask=-1 task=Build

Skaffold executed from a module/subfolder

DEBU[0000] Running command: [java -version]              subtask=-1 task=Build
DEBU[0000] Running command: [gradle _skaffoldFailIfJibOutOfDate -Djib.requiredVersion=1.4.0 :service1:_jibSkaffoldFilesV2 -q --console=plain]  subtask=-1 task=Build
 - service1: Error checking cache.
DEBU[0000] Running command: [tput colors]                subtask=-1 task=DevLoop
DEBU[0000] Command output: [256
]                        subtask=-1 task=DevLoop
getting hash for artifact "service1": getting dependencies for "service1": could not fetch dependencies for workspace .: initial Jib dependency refresh failed: failed to get Jib dependencies: starting command gradle _skaffoldFailIfJibOutOfDate -Djib.requiredVersion=1.4.0 :service1:_jibSkaffoldFilesV2 -q --console=plain: exec: "gradle": executable file not found in $PATH
sergeykad commented 3 months ago

I found the relevant documentation here.

"Set the artifact’s context field to the root project location."

It still would be nice if the context could be detected automatically by going up in the folder tree until "gradle.settings" or Gradle wrapper script is found.