GitLab Ci Caching?

Hi , I trying to cache the scala & coursier dependencies.
Getting the following error,

WARNING: /cache: not supported: outside build directory
WARNING: /cache/.coursier: not supported: outside build directory

How to add the files to build directory and cache them? Please help

Thanks!

It looks like you’re trying to cache a directory at the root of the system rather than inside the build directory. You should try using cache/ rather than /cache/ and see if that works?

If it doesn’t, could you share your .gitlab-ci.yml?

[quote=“robin112, post:1, topic:5603” ]@connorshea
coursier
[/quote]

still its not working!
.gitlab-ci.yml

stages:

  • build
  • test
  • publish
  • cleanup

cache:
key: “$CI_BUILD_REF_NAME”
paths:
- cache/

create:
type: build
script:
- docker build --rm --pull -t docker.ticketnetwork.com/sbt:latest -f Dockerfile .

lint:
type: test
image: docker.ticketnetwork.com/sbt
script:
- sbt scalastyle
- sbt scalafmtTest

unit tests:
type: test
image: docker.ticketnetwork.com/sbt
script:
- sbt test

publish jar:
type: publish
image: docker.ticketnetwork.com/sbt
script:
- sbt assembly
- sbt publish
only:
- master

remove containers:
type: cleanup
script:
- docker rmi -f docker.ticketnetwork.com/sbt:latest
when: always
~

Archiving cache…
cache/: found 2336 matching files
Archive is up to date!

Build succeeded.

but the cached files are called during the next build.It is downloading everything and not using the cached files.

gitlab-ci-multi-runner 1.0.4 (014aa8c)
Using Docker executor with image docker.ticketnetwork.com/sbt
Pulling docker image docker.ticketnetwork.com/sbt
WARNING: Cannot pull the latest version of image docker.ticketnetwork.com/sbt : unauthorized: authentication required
WARNING: Locally found image will be used instead.

Running on runner-3bc1519e-project-140-concurrent-0 via 3b8236cb8bd1…
Fetching changes…
Removing cache/
Removing project/project/
Removing project/target/
Removing target/
HEAD is now at 9fe33aa target
Checking out 9fe33aa0 as git_cache…
HEAD is now at 9fe33aa… target
Restoring cache…
Done!