0

Is there a way (like with Jenkins maven plugin) to set the .ivy2/cache dir
local to the workspace of a sbt job in Jenkins? The motivation is to be able to perform a 'clean' build each time.
If not, is there some other way I can validate that all sbt dependencies are resolved from external repositories during the build, and not from local cache?

Eli Golin
  • 373
  • 1
  • 16

1 Answers1

0

For changing default ivy home, take a look at this SO post.
One other possible solution is to add Execute Shell step prior to Build using sbt:

rm -rf ~/.ivy2/cache
anamar
  • 324
  • 4
  • 8
  • So I guess there is nothing currently builtin into the sbt plugin itself. Overriding the default .ivy2/cache location as a system property seems like a good idea. The 'rm -rf ~/.ivy2/cache' will break parallel jobs, so it is not a solution. – Eli Golin Jun 17 '18 at 08:20
  • I agree, overriding is cleaner. Maybe reuse combination of Jenkins env variables 'WORKSPACE', 'BUILD_NUMBER' when overriding default cache location. Don't forget to cleanup cache directories so they don't pile up. – anamar Jun 17 '18 at 11:07
  • From what I've checked (with sbt 1.0.4) the -Divy.home property has no effect on sbt only the -Dsbt.ivy.home which defines the .ivy location for all downloaded artifacts including the sbt and the scala lang itself. It's a pity I will have to download all those heavy dependencies each time when a CI job fires and cleans the workspace. – Eli Golin Jun 18 '18 at 13:03