JHipster Jenkins 构建损坏

JHipster Jenkins build broken

我必须解决现有 JHipster 项目的构建问题。前两天还好好的,不知道怎么回事。 基本上,这是为 JHipster 中的 3 个微服务构建的 Jenkins。构建依赖于 docker 图像并使用 maven 包装器 mvnw。 这是 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"
                    }

.\mvnw clean 指令构建失败。 我们可以在下面的日志中看到,一个名为“/tmp”的附加目标被插入并且系统未知。它是 Reactor Build 计划的一部分。 我在我们的项目中搜索了这个字符串,但没有找到它的来源。

构建日志:

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

我的问题是:

  1. "clean" 目标在哪里定义?我相信这是核心 Maven 目标的一部分,但我想确定如果我有机会验证那里没有定义 /tmp。
  2. 这个“/tmp”目标在哪里定义的?如何删除或修复它?
  3. 我应该更改我的 docker 图片并再拍一张吗?在这种情况下,知道我需要 Jdk 11.

谢谢 克里斯托夫

一位同事找到了解决方案。 变量 MAVEN_CONFIG 设置不当。

因此需要在 jenkinsfile 中写入:

sh "unset MAVEN_CONFIG && ./mvnw clean"