Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usage of "-SNAPSHOT" dependencies breaks Gradle builds #9535

Open
wdforson-sada opened this issue Oct 1, 2024 · 0 comments
Open

usage of "-SNAPSHOT" dependencies breaks Gradle builds #9535

wdforson-sada opened this issue Oct 1, 2024 · 0 comments

Comments

@wdforson-sada
Copy link

wdforson-sada commented Oct 1, 2024

Expected behavior

When I run skaffold build -p $profile to execute a Jib build for my Gradle project, which consumes one or more "-SNAPSHOT" dependencies, Skaffold successfully uploads a "source archive" to GCS, downloads and unpacks that archive, and proceeds with the build as configured.

Actual behavior

With the following profile definition:

  - name: dev
    build:
      googleCloudBuild:
        projectId: $gcpProjectId
        gradleImage: gradle:8.2.1-jdk17-alpine
      artifacts:
        - image: $destinationContainerRepo
          jib:
            type: gradle
            project: service

skaffold build -p dev fails like so:

Pushing code to gs://my-cloudbuild-bucket/source/source-archive-prefix-<archive hash>.tar.gz
uploading source archive: uploading sources to google storage: Rel: can't make /Users/me/.gradle/caches/modules-2/files-2.1/my.org/my-shared-lib/0.0.1-SNAPSHOT/<archive hash>/my-shared-lib-0.0.1-SNAPSHOT.jar relative to .

If I add context: $absolutePathToProjectRoot to the build artifact in the above profile config, skaffold build -p dev fails like so:

Fetching storage object: gs://my-cloudbuild-bucket/source/source-archive-prefix-<archive hash>.tar.gz#$epochTimestampMicros
Copying gs://my-cloudbuild-bucket/source/source-archive-prefix-<archive hash>.tar.gz#$epochTimestampMicros...
/ [1 files][ 14.2 MiB/ 14.2 MiB]
Operation completed over 1 objects/14.2 MiB.
tar: Removing leading `../../../' from member names
tar: ../../../.gradle/caches/modules-2/files-2.1/my.org/my-shared-lib/0.0.1-SNAPSHOT/<archive hash>/my-shared-lib-0.0.1-SNAPSHOT.jar: Member name contains '..'
tar: Exiting with failure status due to previous errors

NOTE: the above failure modes occur only when my project is configured to consume a -SNAPSHOT version of the relevant dependency (since this prompts Skaffold/Jib to include a copy of the dependency in the sources archive). The build works fine if I change the Gradle dependency config to consume my-shared-lib:0.0.1 rather than my-shared-lib:0.0.1-SNAPSHOT.

I would suspect there is some way to configure Skaffold and/or Jib to work around this (aside from nuclear options such as running builds in the same directory as the Gradle cache or setting GRADLE_USER_HOME to force the creation of a brand new cache directory in the build directory)...but I'm not finding it.

Thanks in advance!

Information

  • Skaffold version: v2.9.0
  • Operating system: macOS 14.7
  • Installed via: Google Cloud SDK
  • Contents of skaffold.yaml: see snippet above (I think that should be sufficient here, but I'm happy to share more if it would be helpful...I'll just need to obfuscate the contents, which is a bit tedious)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@wdforson-sada and others