Sbt: plugins fail to load in Jenkins

Created on 14 Oct 2019  路  3Comments  路  Source: sbt/sbt

Since sbt 1.3.X, sometimes my Jenkins build fail to compile the build.sbt. It looks like the plugins are not loaded.

steps

sbt.version=1.3.2

problem

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)
                 ^

expectation

should compile just fine

notes

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

Screenshot from 2019-10-14 17-26-22

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?

Bug

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 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 ?

All 3 comments

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 ?

Was this page helpful?
0 / 5 - 0 ratings