Search code examples
dockerjenkinsmaven-2jhipster

JHipster Jenkins build broken


I have to fix a build issue on an existing JHipster project. It was building fine a couple of days ago, so I don't know what happened. Basically, this is a Jenkins build for 3 microservices in JHipster. Build relies on docker images and uses maven wrapper mvnw. Here is an excerpt of the jenkinsfile:

        parallel 'Gateway': {
            dir('jh-ambient-gateway') {

                docker.image('registry.hub.docker.com/circleci/openjdk:11.0-jdk-stretch-node-browsers').inside("--group-add ${dockerGroup} -v /var/run/docker.sock:/var/run/docker.sock") {

                    stage('check java') {
                        sh "java -version"
                    }

                    stage('clean') {
                        sh "chmod +x mvnw"
                        sh "./mvnw clean"
                    }

                    stage('install tools') {
                        sh "./mvnw com.github.eirslett:frontend-maven-plugin:install-node-and-npm -DnodeVersion=v12.14.1 -DnpmVersion=6.13.0"
                    }

                    stage('npm install') {
                        sh "./mvnw com.github.eirslett:frontend-maven-plugin:npm"
                    }

Build fails on the .\mvnw clean instruction. We can see in the logs below that an addition goal named "/tmp" is inserted and unknown to the system. It is part of the Reactor Build plan. I searched for this string in our project and did not find from where it could come from.

The build log:

[DEBUG] Writing tracking file /home/node/.m2/repository/org/springframework/session/spring-session-bom/Bean-SR8/_remote.repositories
[DEBUG] Writing tracking file /home/node/.m2/repository/org/springframework/session/spring-session-bom/Bean-SR8/spring-session-bom-Bean-SR8.pom.lastUpdated
[DEBUG] === REACTOR BUILD PLAN ================================================
[DEBUG] Project: com.xxxx.yyyy:zzzz:jar:0.0.1-SNAPSHOT
[DEBUG] Tasks:   [/tmp, clean]
[DEBUG] Style:   Regular
[DEBUG] =======================================================================
[INFO] 
[INFO] -------------------< com.xxxx.yyyy:zzzz >-------------------
[INFO] Building zzzz 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[DEBUG] Lifecycle default -> [validate, initialize, generate-sources, process-sources, generate- resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy]
[DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean]
[DEBUG] Lifecycle site -> [pre-site, site, post-site, site-deploy]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.354 s
[INFO] Finished at: 2020-03-31T11:58:55Z
[INFO] ------------------------------------------------------------------------
[ERROR] Unknown lifecycle phase "/tmp". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
org.apache.maven.lifecycle.LifecyclePhaseNotFoundException: Unknown lifecycle phase "/tmp". You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy.
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateLifecycleMappings (DefaultLifecycleExecutionPlanCalculator.java:248)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateMojoExecutions (DefaultLifecycleExecutionPlanCalculator.java:217)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan (DefaultLifecycleExecutionPlanCalculator.java:126)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleExecutionPlanCalculator.calculateExecutionPlan (DefaultLifecycleExecutionPlanCalculator.java:144)
    at org.apache.maven.lifecycle.internal.builder.BuilderCommon.resolveBuildPlan (BuilderCommon.java:97)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:111)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:566)
    at org.apache.maven.wrapper.BootstrapMainStarter.start (BootstrapMainStarter.java:39)
    at org.apache.maven.wrapper.WrapperExecutor.execute (WrapperExecutor.java:122)
    at org.apache.maven.wrapper.MavenWrapperMain.main (MavenWrapperMain.java:61)

My questions would be:

  1. Where is the "clean" goal defined? I believe it is part of core maven goals but I would like to be sure so if I have a chance to verify the /tmp is not defined there.
  2. Where it this "/tmp" goal defined? How to remove it or fix it?
  3. Should I change my docker image and take another one? In this case which one knowing that I need Jdk 11.

Thank you Christophe


Solution

  • A colleague found out the solution. The variable MAVEN_CONFIG is unproperly set.

    So need to write this in jenkinsfile:

    sh "unset MAVEN_CONFIG && ./mvnw clean"