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

Can't cache gradle dependencies with message "no such file or directory" #235

Open
KangbingZhao opened this issue Dec 5, 2022 · 1 comment

Comments

@KangbingZhao
Copy link

KangbingZhao commented Dec 5, 2022

Describe the bug
can't cache gradle dependencies.

I mount host directory /tmp/cache/gradle as cache.

I checked that it's exact gradle depedencies directory.
image

but rebuilding cache failed
image

To Reproduce
Steps to reproduce the behavior:

kind: pipeline
type: docker
name: test
steps:
  - name: restore-cache-with-filesystem
    image: meltwater/drone-cache
    pull: if-not-exists
    settings:
      backend: "filesystem"
      restore: true
      cache_key: "volume"
      archive_format: "gzip"
      mount:
        - "/root/.gradle/caches"
    volumes:
      - name: cache
        path: /tmp/cache/gradle
  - name: pre
    image: openjdk:17-jdk-slim
    volumes:
      - name: sock
        path: /var/run/docker.sock
    commands:
      - ./gradlew build -profile -i
      - cd /root/.gradle
      - ls -a
  - name: rebuild-cache-with-filesystem
    image: meltwater/drone-cache
    pull: if-not-exists
    settings:
      backend: "filesystem"
      rebuild: true
      cache_key: "volume"
      archive_format: "gzip"
      # filesystem_cache_root: "/tmp/cache"
      mount:
        - "/root/.gradle/caches"
    volumes:
      - name: cache
        path: /tmp/cache/gradle
volumes:
  - name: sock
    host:
      path: /var/run/docker.sock
  - name: cache
    host:
      path: /tmp/cache/gradle

Specifications

  • Version: drone 2.15.0
  • Platform: Linux
  • Subsystem: Ubuntu 20.04 in WSL2
@profound7
Copy link

It seems that caching doesn't work outside of the working directory (/drone/src) as that is the directory that drone retains across steps (correct me if I'm wrong). I'm trying to cache .m2 directory. Here's some additional information.

These mount directories don't work:

  • /root/.m2/repository
  • ../../root/.m2/repository

This work, but I have to let maven know:

  • .m2/repository

I either have to use maven like so mvn -Dmaven.repo.local=.m2/repository ... or set environment variable MAVEN_OPTS=-Dmaven.repo.local=.m2/repository

So for gradle, or other programs, you have to check and see if there's a way to specify a custom directory. I hope this plugin could support caching outside of the /drone/src directory.

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