Since sbt 1.3.X, sometimes my Jenkins build fail to compile the build.sbt. It looks like the plugins are not loaded.
sbt.version=1.3.2
fails to compile build.sbt
/home/jenkins/agent/workspace/myproject_master/build.sbt:7: error: not found: value dockerRepository
dockerRepository := Some("..."),
^
/home/jenkins/agent/workspace/myproject_master/build.sbt:8: error: not found: value dockerExposedPorts
dockerExposedPorts := Seq(9005),
^
/home/jenkins/agent/workspace/myproject_master/build.sbt:9: error: not found: value dockerBaseImage
dockerBaseImage := "openjdk:8",
^
/home/jenkins/agent/workspace/myproject_master/build.sbt:10: error: not found: value Universal
javaOptions in Universal ++= Seq(
^
/home/jenkins/agent/workspace/myproject_master/build.sbt:27: error: not found: value scalafixSemanticdb
addCompilerPlugin(scalafixSemanticdb),
^
/home/jenkins/agent/workspace/myproject_master/build.sbt:42: error: not found: value JavaAppPackaging
.enablePlugins(JavaAppPackaging)
^
should compile just fine
I'm using the Jenkins sbt plugin
https://wiki.jenkins.io/display/JENKINS/sbt+plugin
I wrote a small utility function:
def run(args) {
def version = "1.3.2"
def sbtInstallation = steps.tool(name: "sbt-${version}", type: 'org.jvnet.hudson.plugins.SbtPluginBuilder$SbtInstallation')
def sbtBin = "${sbtInstallation}/bin/sbt"
def baseArgs = [
"-Dsbt.log.noformat=true",
"-Dfile.encoding=utf-8",
"-J-Xms512M",
"-J-Xmx1024M",
"-J-Xss16M",
"-J-XX:MaxMetaspaceSize=512m"
].join(" ")
def extraArgs = args.join(" ")
def command = "$sbtBin $baseArgs $extraArgs"
steps.sh(command)
}
Then I use it like this: run(['compile'])
Here is my Global Tool Configuration

It works fine with sbt 1.2.6 but not with sbt 1.3.3. I saw in the changelog that there are some changes with the plugin loading mechanism. Maybe that's the issue?
Looks very similar to issue reported by me https://github.com/sbt/sbt/issues/5142 that is still present in sbt-1.3.3.
I had similar symptoms when running sbt 1.3.x within a container - the second invocation would always fail complaining about references to plugins & plugin keys not built-in. It turned out to be a missing docker volume mount to persist the coursier cache accros invocations: references to plugins previously resolved by sbt as dependencies in the meta build pointed at non-existing files, and the scalac classpath for build.sbt ended up silently partial.
Could it be a similar filesystem mismatch between the project/target files and the coursier cache ?
Likely fixed in https://github.com/sbt/sbt/pull/5303
Most helpful comment
I had similar symptoms when running sbt 1.3.x within a container - the second invocation would always fail complaining about references to plugins & plugin keys not built-in. It turned out to be a missing docker volume mount to persist the coursier cache accros invocations: references to plugins previously resolved by sbt as dependencies in the meta build pointed at non-existing files, and the
scalacclasspath forbuild.sbtended up silently partial.Could it be a similar filesystem mismatch between the
project/targetfiles and the coursier cache ?