title: GitLab Runner cache for Gradle is not working
body: <p>I'm using GitLab Runner as CI to build an Android project however the cache is not working.</p>
  
  <p>Here's my <code>.gitlab-ci.yml</code>. It was modified from <a href="https://gist.github.com/daicham/5ac8461b8b49385244aa0977638c3420" rel="nofollow noreferrer">https://gist.github.com/daicham/5ac8461b8b49385244aa0977638c3420</a>.</p>
  
  <pre><code>image: runmymind/docker-android-sdk:latest
  variables:
    GRADLE_USER_HOME: $CI_PROJECT_DIR/.gradle
  stages:
    - build
  debug:
    stage: build
    script:
      - set +e
      - du -sh $CI_PROJECT_DIR/.gradle/wrapper
      - du -sh $CI_PROJECT_DIR/.gradle/caches
      - set -e
      - ./gradlew assembleDebug
      - mkdir artifacts
      - cp mobile/build/outputs/apk/*.apk artifacts/
      - cp wear/build/outputs/apk/*.apk artifacts/
    cache:
      paths:
        - .gradle/wrapper/
        - .gradle/caches/
        - build/
        - mobile/build/
        - wear/build/
    artifacts:
      name: "project_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
      expire_in: 2 weeks
      paths:
        - artifacts/
  </code></pre>
  
  <p>And the log:</p>
  
  <pre><code>Running with gitlab-ci-multi-runner 9.0.0 (08a9e6f)
  Using Docker executor with image runmymind/docker-android-sdk:latest ...
  Using docker image sha256:d696fa13188c8d2d121c86cf526201b363c1e34ee7b163d6ce1ab1718f91a5e6 ID=sha256:d696fa13188c8d2d121c86cf526201b363c1e34ee7b163d6ce1ab1718f91a5e6 for predefined container...
  Pulling docker image runmymind/docker-android-sdk:latest ...
  Using docker image runmymind/docker-android-sdk:latest ID=sha256:474ac98077a496f2f71aa22ce4eebcea966c2960a061d4a59babe81ff007009b for build container...
  Running on runner-8ce5d03c-project-72-concurrent-0 via outrage...
  Cloning repository...
  Cloning into '/builds/User/android-project'...
  Checking out 015d01d0 as master...
  Skipping Git submodules setup
  Checking cache for default...
  Successfully extracted cache
  $ set +e
  $ du -sh $CI_PROJECT_DIR/.gradle/wrapper
  du: cannot access '/builds/User/android-project/.gradle/wrapper': No such file or directory
  $ du -sh $CI_PROJECT_DIR/.gradle/caches
  du: cannot access '/builds/User/android-project/.gradle/caches': No such file or directory
  $ set -e
  $ ./gradlew assembleDebug
  Downloading https://services.gradle.org/distributions/gradle-3.4.1-all.zip
  Unzipping /builds/User/android-project/.gradle/wrapper/dists/gradle-3.4.1-all/c3ib5obfnqr0no9szq6qc17do/gradle-3.4.1-all.zip to /builds/User/android-project/.gradle/wrapper/dists/gradle-3.4.1-all/c3ib5obfnqr0no9szq6qc17do
  Set executable permissions for: /builds/User/android-project/.gradle/wrapper/dists/gradle-3.4.1-all/c3ib5obfnqr0no9szq6qc17do/gradle-3.4.1/bin/gradle
  Starting a Gradle Daemon (subsequent builds will be faster)
  Download https://jcenter.bintray.com/com/android/tools/build/gradle/2.3.0/gradle-2.3.0.pom
  (more downloads)
  </code></pre>
  
  <p>I have also tried using gradle argument to set gradle user home, aggressively specifying <code>.gradle/</code> for cache, etc, but none of them worked.</p>
  
  <p>Any ideas?</p>