Search code examples
eclipsemavendockerjenkinsxtext

xtext maven build fails under Jenkins/docker


I'm working on an xtext DSL project using xtext2.13/java8. It all builds and executes regression tests under maven, and now I want to move the build to run under CI with Jenkins. The Jenkins job runs maven in a docker image. I'm specifically using the docker image "maven:3.5-jdk-8". I can see that the build starts -- log shows p2 dependencies being downloaded, but it then fails with this exception:

[INFO] Downloaded from central: https://repo.maven.apache.org/maven2/org/eclipse/tycho/org.eclipse.tycho.p2.tools.impl/1.0.0/org.eclipse.tycho.p2.tools.impl-1.0.0.jar (48 kB at 630 kB/s)
[WARNING] Error initializing: org.eclipse.tycho.p2.resolver.P2DependencyResolver@72725ee1
java.lang.RuntimeException: java.lang.IllegalStateException: Service is not registered class='interface org.eclipse.tycho.core.shared.ProxyServiceFacade'
at org.eclipse.sisu.equinox.embedder.internal.DefaultEquinoxEmbedder.checkStarted (DefaultEquinoxEmbedder.java:312)
...

I can run the docker/maven build in a local docker and it works fine. I'm only seeing this error when I run it in a Jenkins pipeline.

The error doesn't give any kind of clue as to what the underlying problem might be. I can only guess that it is likely to be one of the following:

  • different access to external repos (but it was able to download dozens of other resources before this)
  • different local permissions (maybe missing permission to some resource?)

Any other suggestions? Thanks


Solution

  • I had the same problem. Posting my solution for reference.

    The root cause was that Maven local repository directory contained a ? in the path (i.e. ?/.m2/repository) and Tycho couldn't resolve the directory properly (regular Maven dependencies were fine). This happens because if you use the --user flag when running the container and inside the container there is no mapping for that user in /etc/passwd the ${user.home} is not properly resolved.

    The solution was to specify the path manually to a valid path in the mvn command, e.g. -Dmaven.repo.local=/path/to/repo

    I guess other options are to:

    • specify the path in Maven settings file, or
    • to have the corresponding user available in the container (e.g. add the addtional argument to the container -v /etc/passwd:/etc/passwd:ro)