skaffold icon indicating copy to clipboard operation
skaffold copied to clipboard

Gradle Jib task dependencies not respected

Open dinvlad opened this issue 3 years ago • 3 comments

Expected behavior

Jib should respect task dependencies specified in build.gradle.

Actual behavior

Jib appears to be using a "raw" jibDockerBuild task, without relying on its possible task dependencies (if those are defined in build.gradle).

Information

  • Skaffold version: v1.35.1
  • Operating system: Ubuntu 20.04.3 LTS
  • Installed via: google-cloud-sdk-skaffold Debian package
  • Contents of skaffold.yaml:
apiVersion: skaffold/v2beta26
kind: Config
build:
  artifacts:
  - image: test-service
    jib: {}

Steps to reproduce the behavior

  1. A build.gradle with these 2 task dependencies:
tasks.jib.dependsOn test
tasks.jibDockerBuild.dependsOn test
  1. skaffold build
  2. gradle jibDockerBuild
  3. Observe that test task is only triggered by (3), but not by (2).

Workaround:

It seems that test task in particular does get triggered sometimes, but only if

  1. The image is not cached and
  2. There's a non-empty test config in skaffold.yaml, for example:
    test:
    - image: busybox
    

Perhaps this behavior should be documented? And what about non-test tasks?

dinvlad avatar Feb 08 '22 02:02 dinvlad

It seems to be somehow related to issue I just logged #7086.

I've observed that when adding tasks.jibDockerBuild.dependsOn test skaffold was not picking up on those changes. Went through gradle clean cycles and it helped, so it seems that there's some sort of caching involved.

artur-jablonski avatar Feb 08 '22 15:02 artur-jablonski

Also I don't think skaffold could bypass what's in build.gradle even if it wanted to. Skaffold runs a task, that task depends on another one as per build.gradle and I don't know how could that be ignored.... but then again I am no gradle expert.

artur-jablonski avatar Feb 08 '22 15:02 artur-jablonski

@related to #7086 Thanks you for the issue. We would appreciate any help from the community on this issue.

tejal29 avatar Mar 22 '22 19:03 tejal29