Search code examples
jenkinssbt-plugin

SBT Plugin in Jenkins creates empty fat jar


We get "successful" builds using the SBT Plugin, but the fat .jar file is missing almost all dependencies. The log looks correct compared to a local build in Intellij.

The file size of the .jar is close to a correct build, so we didn't immediately notice the problem, but obviously the checksum is wrong.

Jenkins jar:

This is the result from Jenkins

Local build in Intellij:

This is a good build

Partial log:

[Deploy ContentSeasonalityScoring to Test] $ cmd.exe /C " java -Dsbt.log.noformat=true -jar d:\Jenk\tools\org.jvnet.hudson.plugins.SbtPluginBuilder_SbtInstallation\SBT_0.13.11\bin\sbt-launch.jar clean "
[info] Loading project definition from D:\Jenk\workspace\MarketingData\Deploy ContentSeasonalityScoring to Test\project
[info] Set current project to ContentSeasonalityScoring (in build file:/D:/Jenk/workspace/MarketingData/Deploy%20ContentSeasonalityScoring%20to%20Test/)
[success] Total time: 16 s, completed Aug 4, 2016 7:00:44 AM
Build step 'Build using sbt' changed build result to SUCCESS
[Deploy ContentSeasonalityScoring to Test] $ cmd.exe /C " java -Dsbt.log.noformat=true -jar d:\Jenk\tools\org.jvnet.hudson.plugins.SbtPluginBuilder_SbtInstallation\SBT_0.13.11\bin\sbt-launch.jar assembly "
[info] Loading project definition from D:\Jenk\workspace\MarketingData\Deploy ContentSeasonalityScoring to Test\project
[info] Set current project to ContentSeasonalityScoring (in build file:/D:/Jenk/workspace/MarketingData/Deploy%20ContentSeasonalityScoring%20to%20Test/)
[info] Updating
{file:/D:/Jenk/workspace/MarketingData/Deploy%20ContentSeasonalityScoring%20to%20Test/}
root...
[info] Resolving org.scala-lang#scala-library;2.10.5 ...
[info] Resolving org.apache.kafka#kafka-clients;0.8.2.1 ...
<etc...>
[info] Compiling 13 Scala sources to D:\Jenk\workspace\MarketingData\Deploy ContentSeasonalityScoring to Test\target\classes...
[info] Compiling 3 Scala sources to D:\Jenk\workspace\MarketingData\Deploy ContentSeasonalityScoring to Test\target\test-classes...
[info] Including: spark-csv_2.10-1.4.0.jar
[info] Including: scala-pickling_2.10-0.10.0.jar
[info] Including: kafka-clients-0.8.2.1.jar
[info] Including: commons-csv-1.1.jar
[info] Including: univocity-parsers-1.5.1.jar
[info] Including: slf4j-api-1.7.6.jar
[info] Including: lz4-1.2.0.jar
[info] Including: argonaut_2.10-6.1.jar
[info] Including: snappy-java-1.1.2.1.jar
[info] Including: quasiquotes_2.10-2.0.1.jar
[info] Including: joda-time-2.9.3.jar
[info] Including: scala-compiler-2.10.4.jar
[info] Including: scalaz-core_2.10-7.1.1.jar
[info] Including: joda-convert-1.8.1.jar
<successful tests...>
[info] Total number of tests run: 53
[info] Suites: completed 3, aborted 0
[info] Tests: succeeded 53, failed 0, canceled 0, ignored 0, pending 0
[info] All tests passed.
[info] Including: monocle-core_2.10-1.1.0.jar
[info] Including: monocle-macro_2.10-1.1.0.jar
[info] Including: scallop_2.10-1.0.1.jar
[info] Including: scala-library.jar
[info] Including: scala-reflect.jar
[info] Checking every .class/.jar file's SHA-1.
[info] Merging files...
[warn] Merging 'NOTICE' with strategy 'rename'
[warn] Merging 'META-INF\NOTICE.txt' with strategy 'rename'
[warn] Merging 'org\xerial\snappy\native\README' with strategy 'rename'
[warn] Merging 'META-INF\LICENSE.txt' with strategy 'rename'
[warn] Merging 'LICENSE' with strategy 'rename'
[warn] Merging 'META-INF\MANIFEST.MF' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.univocity\univocity-parsers\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\com.univocity\univocity-parsers\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\joda-time\joda-time\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\joda-time\joda-time\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.apache.commons\commons-csv\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.apache.commons\commons-csv\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.joda\joda-convert\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.joda\joda-convert\pom.xml' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.slf4j\slf4j-api\pom.properties' with strategy 'discard'
[warn] Merging 'META-INF\maven\org.slf4j\slf4j-api\pom.xml' with strategy 'discard'
[warn] Merging 'rootdoc.txt' with strategy 'concat'
[warn] Strategy 'concat' was applied to a file
[warn] Strategy 'discard' was applied to 11 files
[warn] Strategy 'rename' was applied to 5 files
[info] SHA-1: 88285925d1f4dc544e3e1abc5ac1c2a24fcde78c
[info] Packaging D:\Jenk\workspace\MarketingData\Deploy ContentSeasonalityScoring to Test\target\ContentSeasonalityScoring-assembly-1.0.jar ...
[info] Done packaging.
[success] Total time: 50 s, completed Aug 4, 2016 7:01:38 AM

I would expect some sort of timeout or failure if the job could not reach the Maven repos. We have jobs running on these servers that pull in npm dependencies over http.


Solution

  • Ummmm... never mind.

    We were using a publish with ssh task to move the .jar to our destination Linux server. As part of that task, we convert all Windows file endings to Unix file endings, but that should only have been done for text files. We inadvertently applied the same command to the .jar file.

    Don't do that.