Cache sbt builds

I want to build scala applications so i use sbt

By default sbt uses ~/.ivy2 ~/.sbt directories to cache library dependencies

image (hseeberger/scala-sbt) defines root as default user when running, so i decided just to move workspace to home directory of root

So i made this pipeline:

  base: /
  path: /root


    image: drillster/drone-volume-cache
    restore: true
      - .sbt
      - .ivy2
      - /tmp/cache:/cache

   image: hseeberger/scala-sbt
     - sbt compile test

    image: drillster/drone-volume-cache
    rebuild: true
      - .sbt
      - .ivy2
      - /tmp/cache:/cache

But it fails when plugin tries to rebuild cache:

[info] downloading ...
[info]  [SUCCESSFUL ] jline#jline;2.14.3!jline.jar (346ms)
[info] Done updating.
[info] Compiling 3 Scala sources to /root/target/scala-2.12/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.12.2. Compiling...
[info]   Compilation completed in 18.186 s
[success] Total time: 35 s, completed Oct 8, 2017 9:05:20 PM
[success] Total time: 0 s, completed Oct 8, 2017 9:05:21 PM
Rebuilding cache for folder .sbt...
rsync: stat "/cache/.sbt/boot/scala-2.10.6/org.scala-sbt/sbt/0.13.16/.compile-0.13.16.jar.Emopng" failed: Bad file descriptor (9)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]
2017/10/09 00:05:25 drone_step_2 : exit code 23

What i did wrong? May be there is a better way, but i think that pipeline should work

This is a generic unix error that may indicate multiple processes were trying to read and write to the file at the same time. Did you have builds running concurrently trying to read and write the cache at the same time? If yes you might want to consider a different cache plugin.

If no, this is difficult to debug because this is an rsync error, and not a Drone error. What would cause rsync to fail with a Bad file descriptor? Disk corruption? File corruption? There could be a number of root causes that have nothing to do with Drone.

Hm, this error occurs when i run that pipeline locally (drone exec)

I’ve pushed commits and drone executes that job successfully and sbt files are cached for next builds (they are not corrupted)

Thanks for clarification, i will take this into account

BTW: I really like drone ci, i’ve just found it two days ago after fighting with jenkins and it’s docker pipeline plugins :slight_smile: